看起来mongodb服务器连接出了问题,但我不知道如何解决这个问题。有没有人遇到过同样的问题,请帮帮我?非常感谢!终端错误信息如下:
(node:63820) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017]
at Pool.<anonymous> (/Users/Harry/Documents/code/testAPI/node_modules/mongodb-core/lib/topologies/server.js:503:11)
at Pool.emit (events.js:127:13)
at Connection.<anonymous> (/Users/Harry/Documents/code/testAPI/node_modules/mongodb-core/lib/connection/pool.js:326:12)
at Object.onceWrapper (events.js:219:13)
at Connection.emit (events.js:127:13)
at Socket.<anonymous> (/Users/Harry/Documents/code/testAPI/node_modules/mongodb-core/lib/connection/connection.js:245:50)
at Object.onceWrapper (events.js:219:13)
at Socket.emit (events.js:127:13)
at emitErrorNT (internal/streams/destroy.js:64:8)
at process._tickCallback (internal/process/next_tick.js:152:19)
(node:63820) 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:63820) [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.发布于 2018-02-27 07:40:18
似乎没有数据库实例在localhost:27017上运行。请确保在运行代码之前启动mongodb实例。
根据您的操作系统,启动mongodb守护进程的过程非常,请参阅https://docs.mongodb.com/manual/tutorial/manage-mongodb-processes/
https://stackoverflow.com/questions/48997872
复制相似问题