gpt4 book ai didi

javascript - 未处理的 promise 拒绝警告 : MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError

转载 作者:可可西里 更新时间:2023-11-01 09:56:22 28 4
gpt4 key购买 nike

我尝试运行以下命令:

node index.js

但是,我从我的终端得到以下信息:

    success connection to port 3000
(node:16767) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError
: connect ECONNREFUSED 127.0.0.1:27017]
at Pool.<anonymous> (/Users/hatchery/Documents/nodejs/fxexpress/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/server.js:503:11
)
at emitOne (events.js:116:13)
at Pool.emit (events.js:211:7)
at Connection.<anonymous> (/Users/hatchery/Documents/nodejs/fxexpress/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js:326:12)
at Object.onceWrapper (events.js:317:30)
at emitTwo (events.js:126:13)
at Connection.emit (events.js:214:7)
at Socket.<anonymous> (/Users/hatchery/Documents/nodejs/fxexpress/node_modules/mongoose/node_modules/mongodb-core/lib/connection/connection.js:245:50)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:64:8)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
(node:16767) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:16767) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

我不确定为什么会收到此错误。谁能建议该怎么做?

最佳答案

如果您使用的是 mongoDB.Atlas,请转到网络访问并设置白名单条目:0.0.0.0/0。 enter image description here

enter image description here

重新运行命令。

关于javascript - 未处理的 promise 拒绝警告 : MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50003575/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com