0

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

8
  • Did you start the daemon first with mongod? Commented May 6, 2017 at 22:13
  • I have already start mongod Commented May 6, 2017 at 22:15
  • So in one terminal window, after starting mongod, you should see this: 2017-05-06T15:18:51.840-0700 I NETWORK [thread1] waiting for connections on port 27017 Do you see that? If not is there something about /data/db? Commented May 6, 2017 at 22:20
  • no, this is my log Commented May 6, 2017 at 22:25
  • 2017-05-07T08:24:01.125+1000 I CONTROL [initandlisten] MongoDB starting : pid=1148 port=27017 dbpath=/data/db 64-bit host=192-168-1-8.tpgi.com.au Commented May 6, 2017 at 22:26

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

You sir are awesome! This was just what I needed.
0

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.

Comments

0

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.