Report this

What is the reason for this report?

Correct bindIP for mongodb config file

Posted on December 22, 2014

Hi,

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: 127.0.0.1 and my droplet: 192.241.xxx.xx. Which one is used for which config file? My YAML file looks as follows for local machine:
systemLog:
	destination:file
    path:"C:\\data\\log\\mongodb.log"
    logAppend:true
processManagement:
	fork:true
net:
	bindIp:127.0.0.1
    port:27017
storage:
	dbPath:"C:\\data"
replication:
	replSetName:"data"


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!

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.

Setting bindIp to 127.0.0.1 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.

Yes, it’s a typical desktop setup. Yes, behind wireless router. I checked my IP using whatsmyip.org - it’s 104.5.xx.xxx, 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.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.