Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused

while trying this mongo command in ubuntu I am getting this error.

    ritzysystem@ritzysystem-Satellite-L55-A:~$ mongo     MongoDB shell version: 2.6.1     connecting to: test     2014-10-06T12:59:35.802+0530 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused     2014-10-06T12:59:35.802+0530 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146     exception: connect failed 

how can I rectify this is anyone had the same problem.

like image 526
Ashish Ranjan Avatar asked Oct 06 '14 07:10

Ashish Ranjan


People also ask

Why is my MongoDB not connecting?

Ensure that your MongoDB instance is running: Compass must connect to a running MongoDB instance. Also check you have installed MongoDB and have a running mongod process. You should also check that the port where MongoDB is running matches the port you provide in the compass connect.

Can't connect to server connection refused MongoDB?

Normally this caused because you didn't start mongod process before you try starting mongo shell. This case worked out for me, i had to do ~>sudo mongod --dbpath /dbpathlocation and then opened the new terminal to run mongo...


1 Answers

Run the following command :

sudo rm /var/lib/mongodb/mongod.lock sudo service mongod restart 

Connection refused to MongoDB errno 111

MacOS:

rm /usr/local/var/mongodb/mongod.lock   sudo service mongod restart 
like image 178
Jagdish Barabari Avatar answered Sep 17 '22 18:09

Jagdish Barabari