How to listen only localhost on MongoDB

MongoDB suggests that an easy way to handle security is to run it in a reliable environment, given that "in this configuration, one should be sure that only trusted machines can access the TCP ports of the database."

What would be the best approach for this? Is there any way that mongodb could only initially listen to localhost?

I am using ubuntu 10.10

+44
mongodb ubuntu
Feb 10 '11 at 18:35
source share
4 answers

Add the following line to mongodb.conf :

 bind_ip = 127.0.0.1 

As @Josh Rickard stated in the comments: don't forget to restart the process after updating the configuration file:

 service mongodb restart 
+93
Aug 29 2018-11-21T00:
source share

As Andreas mentioned in the circle:

 mongod --bind_ip 127.0.0.1 
+33
Feb 10 '11 at 18:58
source share

Note that although it did not appear in the documentation the last time I checked, you can also put this parameter in a .conf file (compared to the command line).

No setting = binding to all ips.

+5
Feb 12 '11 at 9:10
source share

No one mentions the location of the mongodb.conf file, which is /etc/mongodb.conf . Double check before executing the following commands.

 echo "bind_ip = 127.0.0.1" >> /etc/mongodb.conf service mongodb restart 
+2
Dec 20 '15 at 22:42
source share



All Articles