Categories
JavaScript Answers

How to fix the ‘Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused’ error with Node MongoDB?

Spread the love

To fix the ‘Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused’ error with Node MongoDB, we remove the Mongo lock file.

To do this, we run

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

to remove the mongod.lock file with rm.

Then we restart the Mongo server with service mongod restart.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *