如何修复:无法连接到数据库MongoNetworkError

25 浏览
0 Comments

如何修复:无法连接到数据库MongoNetworkError

我正在使用Angular7构建一个程序,我尝试使用远程的MongoDB数据库。

在我的DB.js文件中,这是我指定要写入的数据库的文件,我使用以下代码:

DB: 'mongodb://192.168.1.249:27017/test'

其中'ip address'代表我的数据库所在服务器的IP地址,'test'是数据库的名称。

当我启动nodemon服务器以访问MongoDB时,我遇到以下错误:

MacBook-Pro-de-mac:api mac$ nodemon server
[nodemon] 1.19.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node server.js`
Listening on port 4000
Can not connect to the databaseMongoNetworkError: connect ECONNREFUSED 192.168.1.249:27017

0