How to resolve MongoDB error errno:111 Connection refused or “exit-code”

MongoDB unclean shutdown error
July 22, 2019

How to resolve MongoDB error errno:111 Connection refused or “exit-code”

Sometime MongoDB didn’t work and give errno:111 Connection refused or “exit-code” error.

Below commands would surely helps you:

sudo chown -R mongodb:mongodb /var/log/mongodb
sudo chown -R mongodb:mongodb /var/lib/mongodb
sudo chmod -R 755 /var/lib/mongodb
sudo chmod -R 755 /var/log/mongodb

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

Restart MongoDB service

sudo systemctl restart mongod

Now you can check MongoDB status.

sudo systemctl status mongod

Leave a Reply