Getting error:

MongoDB shell version v3.4.10
connecting to: mongodb://
2018-01-17T20:21:16.583+0530 W NETWORK  [thread1] Failed to connect to, in(checking socket for error after poll), reason: Connection refused
2018-01-17T20:21:16.584+0530 E QUERY    [thread1] Error: couldn't connect to server, connection attempt failed :
exception: connect failed

Attached the screen shot SS of Error

  1. Similar issue was discussed here

In that case removing the below file solve the problem:

sudo rm /tmp/mongodb-27017.sock

followed by launching mongo service again, solve the problem

  1. Similar problem, with different source was discussed here

In this case /tmp permission got corrupted and it was solved by fixing /tmp by running:

sudo chown root:root /tmp
sudo chmod 1777 /tmp

Another option might be that /tmp/mongodb-27017.sock is not owned by mongodb - which can be fixed by (note that solution #1 above which delete the file should solve the wrong ownership issue as well):

sudo chown mongodb:mongodb /tmp/mongodb-27017.sock

Note that: providing relevant logs, might help identifying the problem. e.g.

tail -30 /var/log/mongodb/mongodb.log 
  • @NaveenKumar - did my answer solve your problem? – Yaron Jan 18 '18 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.