As the title suggests. If I set the net.bindIp setting in mongod.conf to on port 27017 this should open it up to all incoming connections. However, if in my ec2 instance I whitelist only my local IP on 27017 will this block all other incoming connections?

I should also note I have a mongodb user with a password set for my db with security.authorization: 'enabled' also set in mongod.conf

Asking for a friend... Thanks

Also please, point me to the correct stackexchange if this is off topic


I didn't get exactly what your friend is trying to do but what can i say is :

Setting net.bindIp to is the same as setting net.bindIpAll to true this will make your server listening on all your available network interfaces on port 27017.

That means that your mongodb instance will be reachable from all networks that can reach your NICs.

Whitelisting only your local ip on 27017 means using security group rules to allow only the inbound ( I guess ) traffic on So if this is the case that means your mongodb instance will be reachable only from your localhost.

Also setting security.authorization: 'enabled' will enable Access Control which wil enforce authentication to your databases using a user and a password.

  • I haven't been able to figure out "recommended practice" for setting up access to mongo This is the only thing I've been able to come up with Nov 4 '20 at 17:31
  • 1
    And it's me.. I'm the friend Nov 4 '20 at 17:31
  • But with what you're saying it seems that only the people I allow on the inbound security group rules should in theory be able to access my mongo database. Because I lied a little bit. I need two IPs plus localhost able to connect to my db. This was the only way I could figure out how with relative ease. Nov 4 '20 at 17:40
  • So you have to whitelist only those needed IPs. Check the following link in order to secure your mongodb instance cyberciti.biz/faq/…
    – Reda Salih
    Nov 4 '20 at 19:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.