Allow Remote Access On MongoDB

By | September 2, 2018

By default MongoDB doesn’t allow remote connections. MongoDB bind to local interface only, it will restrict the remote connections, besides that to allow LAN connections from Application Server open and modify your mongod.conf file like below.

In this tutorial i’m using:

Allow Remote Access On MongoDB (Public Access)

$ nano /etc/mongod.conf

# /etc/mongod.conf

# Listen to Any/Public.
bindIp =

then restart mongod.conf file to take effect with this command “sudo service mongod restart“. Because if you not restart your new configuration, you will not take any effect on your system.

Allow Remote Access On MongoDB

Allowing IpTables Firewall For Public Access

Finally, allow connections on port 27017 to your firewall.

iptables -A INPUT -p tcp --dport 27017 -j ACCEPT


In this tutorial, you have learned how to enable remote access to a MongoDB server. For another mongoDB tutorial you can learn from official documentation. Also do not forget to learn how to use mongoDB in real world programming with spring data mongoDB for inserting, updating and deleting data in mongoDB.


Leave a Reply

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