Reputation: 11
I'm newer to mongode, I use shell to start mongodb service but failed and get following error. What should I do?
mongod log enter image description here
mongo log
MongoDB shell version v3.4.4
connecting to: mongodb://127.0.0.1:27017
2017-05-07T07:59:40.141+1000 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2017-05-07T07:59:40.142+1000 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:237:13
@(connect):1:6
exception: connect failed
Upvotes: 0
Views: 2453
Reputation: 11
Step 1: Please check whether you have C:\data\db. If you dont have it create it manually.
Step 2: in command line go to directory of mongodb such as c:\Program files\Mongodb\server\3.4\bin and type *mongod
Step 3: type Mongo
Hopefully its gonna work out for you.
Upvotes: 0
Reputation: 2144
Make sure the MongoDB server (mongod
) is listening on the right interface.
Listening on 127.0.0.1
(loopback interface) will only work locally. If you want to handle remote requests you will have to listen on a network interface that can be accessed remotely. Listening on 0.0.0.0
will listen on all network interfaces.
Upvotes: 0
Reputation: 746
Try this. Open terminal, and at the prompt type:
sudo chown -R `id -un` /data/db
Exactly as written. This will give you write access to the /data/db directory which is what Mongo is complaining about. It should prompt you for your password. Once it does enter it and hit enter. After that, kill mongod, if running, and restart.
Upvotes: 2