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
.