首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我试着用node.js,express和mongodb来构建API。安装nodemon后,mongodb出错

我试着用node.js,express和mongodb来构建API。安装nodemon后,mongodb出错
EN

Stack Overflow用户
提问于 2018-02-27 06:05:33
回答 1查看 46关注 0票数 0

看起来mongodb服务器连接出了问题,但我不知道如何解决这个问题。有没有人遇到过同样的问题,请帮帮我?非常感谢!终端错误信息如下:

代码语言:javascript
复制
(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.
EN

回答 1

Stack Overflow用户

发布于 2018-02-27 07:40:18

似乎没有数据库实例在localhost:27017上运行。请确保在运行代码之前启动mongodb实例。

根据您的操作系统,启动mongodb守护进程的过程非常,请参阅https://docs.mongodb.com/manual/tutorial/manage-mongodb-processes/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48997872

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档