Ubuntu: 14.04
MongodB version: 3.2.6
MongoDB shell version: 3.2.6 connecting to: test
2017-06-26T07:46:48.195+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2017-06-26T07:46:48.196+0000 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:229:14
@(connect):1:6 exception: connect failed
Hi guys,
Our service contains both mongodb and mongod service. We used to run mongod service (sudo service mongod start) however recently when re run mongod service, we got the error above.
However this problem didn't happen when we run mongodB service .
This is the mongod.conf file. Wonder who can give me some advice? Thanks!
storage:
smallFiles: true
dbPath: /var/lib/mongodb
journal:
enabled: true
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
net:
port: 27017
bindIp: [127.0.0.1,X.X.X.X]
replSet=spof
replication:
replSetName: rs0
Best Answer
It might be due to permission issues with your db directory (dbPath). You can try giving appropriate permission to your directory. Try the following steps:
Give permission to
/var/lib/mongodb
directory.Try to start mongod service.
Check status of mongod service.