简体   繁体   English

Mongodb未在Node js中连接

[英]Mongodb Not connecting in Node js

In Node js using mongodb for saving user chat and users. 在Node js中,使用mongodb保存用户聊天和用户。 All the work is done on local. 所有工作都在本地完成。 Mongodb work properly but today not connected and return following error. Mongodb正常工作,但今天没有连接,并返回以下错误。

{ [MongoError: connect ECONNREFUSED] name: 'MongoError', message: 'connect ECONNREFUSED' {[[MongoError:连接ECONNREFUSED]名称:“ MongoError”,消息:“ connect ECONNREFUSED”

and my code is 我的代码是

代码截图

Sounds like mongod server isn't running. 听起来好像mongod服务器未运行。 The mongod command won't work if your MongoDB installation doesn't have rights outside the core mongo directory. 如果您的MongoDB安装在核心mongo目录之外没有权限,则mongod命令将不起作用。 This is common on Windows installations, especially. 特别是在Windows安装上,这很常见。

Try changing your working directory in your terminal to your Mongo installation directory. 尝试将终端中的工作目录更改为Mongo安装目录。 On a Windows machine, eg cd C:\\Program Files\\Mongo then run mongod --dbpath (yourAppDBdirectory) . 在Windows计算机上,例如cd C:\\Program Files\\Mongo然后运行mongod --dbpath (yourAppDBdirectory)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM