i'm getting following error while connecting to mongodb server

江枫思渺然 提交于 2021-02-17 06:42:11

问题


$ mongo

MongoDB shell version v3.6.3 connecting to: mongodb://127.0.0.1:27017 2018-10-18T17:09:03.003+0530 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused 2018-10-18T17:09:03.004+0530 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed : connect@src/mongo/shell/mongo.js:251:13 @(connect):1:6 exception: connect failed


回答1:


what OS are you using? In ubuntu you need to check your version:

service mongod status, mongod --version.

If mongod is off then just restart and write the error if possible.

service mongod restart



回答2:


if you are using linux, try this command

$ sudo mongod

you are getting that because you are running

$ mongo



回答3:


First go to your mongoDB directory and in that directory go to bin directory and open terminal in that directory(bin), then run the following command:

mongod.exe

After that open another terminal in same directory and run the following command.

mongo.exe

It will resolve this issue.




回答4:


first you check it mongodb proper installed or not and also check it version compatibility


I am saying windows os setup, set environment variable is path C:\Program Files\MongoDB\Server\3.6\bin; then open your command prompt and type

mongod

after open another command prompt and type

mongo


来源:https://stackoverflow.com/questions/52873172/im-getting-following-error-while-connecting-to-mongodb-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!