Report this

What is the reason for this report?

MongoDB http interface is not working

Posted on June 30, 2014

Hello, i want to open MongoDB HTTP Interface ( http://docs.mongodb.org/ecosystem/tools/http-interfaces) 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



This textbox defaults to using Markdown to format your 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 http://dbversity.com/mongodb-shard-creation-script/ for the automated shard creation script.

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

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

sudo service mongod restart

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.