How to disable remote connections to MongoDB?

4.9k views Asked by At

Normally the answer to question is to set:

bindIp: 127.0.0.1

I have this set in /etc/mongod.conf. Unfortunately I am still allowed access to this database remotely. I have restarted the Mongo service a couple times, to no avail.

Does anyone have an idea as to why my database is still accessible remotely?

I'm using MongoDB version 3.0.9

4

There are 4 answers

0
awimley On BEST ANSWER

Remoting in to mongod clients using bindIp = 127.0.0.1 is possible through an SSH tunnel because the shell session is seen as 127.0.0.1.

1
Clement Amarnath On
0
staminna On

Perhaps you must specify the mongodb.conf file when loading your mongod instance. Like so:

mongod --fork --config /etc/mongodb.conf --logpath mongodblogs/mongodb.log --dbpath mongod

0
Nikola Lukic On

This is best variant in security aspect:


 su <NOTROOTUSER>
 mongod --dbpath data --bind_ip localhost

Create new user on you server then log in. Root is not recommended for running mongo server.