Share mongoDB in two droplets

I have two droplets and I want both of them to share the same MongoDB. Is it possible? I tried to get the MongoURL so I include it in both my meteor.js projects but I found no way to get it. I bet it’s quite easy.

I’d truly appreciate any help you can give me.


Submit an 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.

In order to enable access over the internet, modify the value of bind_ip in /etc/mongod.conf By default, it is set to which only allows local access. Changing the value to the IP address of your Droplet will allow external connections. Before doing so, please remember to review the MongoDB security checklist.

# network interfaces
  port: 27017

You will need to restart MongoDB for the changes to take effect:

sudo service mongod restart

In addition to enabling one of the forms of authentication supported by MongoDB, setting up a firewall that only allows remote connections from specific IP addresses is a good security measure to implement. On Ubuntu, you can do this with UFW. The following commands will setup a basic firewall which will allow all outgoing connections from your server but only allow incoming connections via SSH or from the specified IP address ( of your other server.

sudo apt-get install ufw
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw allow from
sudo ufw enable

Using your Droplet’s private IP address is also a good idea.