MongoDB http interface is not working

  • Posted June 30, 2014

Hello, i want to open MongoDB HTTP Interface ( but i can open http://188.226.225.xx:28017/news/news. I am add a rule to iptables : sudo iptables -I INPUT -p tcp -m state --state NEW,ESTABLISHED --dport 27017 -j ACCEPT But something wrong. Please. help ,me


What I did was follow the instruction in the mongod.conf file

$ sudo vim /etc/mongod.conf

Comment the bind_ip value.

# Listen to local interface only. Comment out to listen on all interfaces.
# bind_ip =

Save the file and restart mongod

$ sudo service mongod restart

Plus, i added iptable rule:

$ sudo iptables -I INPUT -p tcp -m tcp --dport 27017 -j ACCEPT

and save the rules

$ sudo iptables-save

That does the trick for me. Hope this help.


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Please refer to for the automated shard creation script.

“mongod” is listening on Because it’s listening on the local loopback interface (, you will be able to connect to it only from the droplet itself. You need to set bindIp to in /etc/mongodb.conf and restart MongoDB:

sudo service mongod restart

First, you need to check if there’s anything listening on port 27017:

sudo netstat -plutn | grep 27017

If you see the mongodb process in the output and still can’t access port 27017, try deleting the existing rule and adding the following rule instead:

sudo iptables -D INPUT -p tcp -m state --state NEW,ESTABLISHED --dport 27017 -j ACCEPT 
sudo iptables -I INPUT -p tcp -m tcp --dport 27017 -j ACCEPT