Connecting to Mongodb on Droplet from app running on AWS instance?

May 16, 2017 1.5k views
MongoDB Ubuntu 16.04

SSH tunneling is great way to connect to MongoDB running on Droplet from local machine and work on local machine but I don't know how to connect to MongoDB Droplet from AWS or from anywhere app.

2 Answers
jtittle1 May 16, 2017
Accepted Answer


Connecting over an SSH Tunnel is probably the most secure means of connecting, though you also have the option of opening remote connections to the MongoDB instance.

In /etc/mongod.conf there's a directive named bind_ip which you can set to the IP of the Droplet (and then restart MongoDB). I would, however, recommend ensuring that you've setup a firewall and are only allowing access to a limited number of IP's if you go that route.

  • Thank you for making it clear that I need to set bindIp to IP of the Droplet. ( you wrote bind_ip but on my version MongoDB 3.4.4 it is bindIp ).

Have another answer? Share your knowledge.