运行Express App

时间:2018-11-22 17:05:36

标签: node.js mongodb express

我是编程新手,目前正在学习MEAN。基本上,尝试从家中运行nodemon服务器时,我收到以下错误消息。当我在学校或本地星巴克时,不会发生此问题。有人可以看看我收到的MongoNetworkError: getaddrinfo ENOTFOUND localhost localhost:27017以下错误,并帮助我理解为什么我无法连接到mongoDB吗?为了澄清起见,是的,我确实有mongod在单独的终端上运行。我在2011年的Macbook Pro上运行macOS High Sierra -v 10.13.4。请帮我。谢谢。

这是我启动服务器时遇到的错误:

  

[nodemon]以node server开头

     

(节点:27636)DeprecationWarning:不建议使用当前URL字符串解析器,并将在以后的版本中将其删除。要使用新的解析器,请将选项{useNewUrlParser:true}传递给MongoClient.connect。

     

在8000端口监听

     

(节点:27636)UnhandledPromiseRejectionWarning:MongoNetworkError:首次连接时无法连接到服务器[localhost:27017] [MongoNetworkError:getaddrinfo ENOTFOUND localhost localhost:27017]       在游泳池。

     

(/ Users / ROBONYX21 / Desktop / Angular / product_list / node_modules / mongodb-core / lib / topologies / server.js:564:11)

     

在Pool.emit(events.js:182:13)      在连接。 >(/用户/ ROBONYX21 /桌面/角度/product_list/node_modules/mongodb-core/lib/connection/pool.js:317:12)      在Object.onceWrapper(events.js:273:13)      在Connection.emit(events.js:182:13)      在套接字。 >(/用户/ ROBONYX21 /桌面/角度/product_list/node_modules/mongodb-core/lib/connection/connection.js:246:50)      在Object.onceWrapper(events.js:273:13)      在Socket.emit(events.js:182:13)      在emitErrorNT上(内部/流/destroy.js:82:8)      在emitErrorAndCloseNT(internal / streams / destroy.js:50:3)      在process._tickCallback(internal / process / next_tick.js:63:19)

     

(节点:27636)UnhandledPromiseRejectionWarning:未处理的承诺拒绝。引发此错误的原因可能是抛出了一个没有catch块的异步函数,或者是拒绝了一个.catch()无法处理的承诺。 (拒绝ID:1)

     

(节点:27636)[DEP0018] DeprecationWarning:已弃用未处理的承诺拒绝。将来,未处理的承诺拒绝将以非零退出代码终止Node.js进程。

这是运行mongod mongod port 27017的终端上显示的内容

2018-11-22T09:48:15.268-0800 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2018-11-22T09:48:20.581-0800 I CONTROL  [initandlisten] 
2018-11-22T09:48:20.581-0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-11-22T09:48:20.581-0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2018-11-22T09:48:20.581-0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2018-11-22T09:48:20.581-0800 I CONTROL  [initandlisten] 
2018-11-22T09:48:20.581-0800 I CONTROL  [initandlisten] ** WARNING: This server is bound to localhost.
2018-11-22T09:48:20.581-0800 I CONTROL  [initandlisten] **          Remote systems will be unable to connect to this server. 
2018-11-22T09:48:20.581-0800 I CONTROL  [initandlisten] **          Start the server with --bind_ip <address> to specify which IP 
2018-11-22T09:48:20.581-0800 I CONTROL  [initandlisten] **          addresses it should serve responses from, or with --bind_ip_all to
2018-11-22T09:48:20.581-0800 I CONTROL  [initandlisten] **          bind to all interfaces. If this behavior is desired, start the
2018-11-22T09:48:20.581-0800 I CONTROL  [initandlisten] **          server with --bind_ip 127.0.0.1 to disable this warning.
2018-11-22T09:48:20.581-0800 I CONTROL  [initandlisten] 
2018-11-22T09:48:20.581-0800 I CONTROL  [initandlisten] 
2018-11-22T09:48:20.581-0800 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000

2018-11-22T09:48:22.917-0800 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'

2018-11-22T09:48:23.545-0800 I NETWORK  [initandlisten] waiting for connections on port 27017

这是我要连接到猫鼬数据库的node.js文件。 mongoose.js

0 个答案:

没有答案