Connection refused to MongoDB errno 111 Connection refused to MongoDB errno 111 mongodb mongodb

Connection refused to MongoDB errno 111


Thanks for the help everyone!

Turns out that it was an iptable conflict. Two rules listing the port open (which resulted in a closed port).

However, one of the comments by aka and another by manu2013 were problems that I would have run into, if not for the conflict.

So! Always remember to edit the /etc/mongod.conf file and set your bind_ip = 0.0.0.0 in order to make connections externally.

Also, make sure that you don't have conflicting rules in your iptable for the port mongo wants (see link on mongodb's site to set up your iptables properly).


Try the following:

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


These commands fixed the issue for me,

sudo rm /var/lib/mongodb/mongod.locksudo mongod --repairsudo service mongod startsudo service mongod status

If you are behind proxy, use:-
export http_proxy="http://username:password@company.com:port/"
export https_proxy="http://username:password@company.com:port/"

Reference: https://stackoverflow.com/a/24410282/4359237