0
votes

$ 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

4

4 Answers

1
votes

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
0
votes

if you are using linux, try this command

$ sudo mongod

you are getting that because you are running

$ mongo
0
votes

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.

0
votes

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