Correct bindIP for mongodb config file


I am trying to setup mongodb replica set as follows:

  1. Primary database on local machine
  2. Secondary database on DO droplet I am not clear what bindIP to use for config files for mongodb on local machine and on remote server (DO droplet). It looks like there is local bindIP: and my droplet: Which one is used for which config file? My YAML file looks as follows for local machine:

Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Yes, it’s a typical desktop setup. Yes, behind wireless router. I checked my IP using - it’s, while when I run ipconfig on my machine, it’s 192.168.x.x. It means that I don’t have static IP as you mentioned. What are the possible solutions?

I am thinking of talking to my ISP and getting static IP or as you mentioned use port forwarding (I am not familiar with it though) to make it static that way.

Thank you for mentioning about security and firewalls. Actually, the reason for not putting this database on remote server is security. I thought that this database will be connected to network only during certain times.

Setting bindIp to will only bind to the local loopback interface. You need to set that to an IP address that is accessible to the server. Is this local machine just a desktop setup? Is it behind a router? You’ll most likely need to set up some port forwarding in order to have an externally and stable IP address.

You’ll also want to read about the security consideration in the MongoDB documentation about making the database accessible externally. You most likely want to to set up firewall rules that only allow connections from whitelisted IP addresses.