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

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

I had the same problem on Mac OS Try to run sudo mongod and in a new terminal tab run mongo


thank you everyone I tried running mongo it was not running finally I found there was no space in my hard disc I emptied some of the space and finally re installed it the same installation procedure as followed to install as given in mongodb docs finally restarted the server and it is running.

https://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu