Connect to MongoDB on Azure (from client)
I am trying to set up my MongoDB dev environment with Azure VM. The VM is up and running MongoDB 2.6.6 and I can SSH to the VM and start MongoDB just fine.
However, I cannot connect to Mongo from any external client (i.e. mongo client or robomongo shell). I am using the public IP address provided to me and using the default port. I also tried editing the /etc/mongodb.conf file to specify the port number (port = 27017) and restart the service .. but that doesn't seem to make any difference.
source to share
I assume this will be migrated to ServerFault. In the meantime: External access requires two things if you've just deployed a new MongoDB instance:
- The
mongod.conf
default setting forbind_ip
is equal127.0.0.1
, which means it ismongod
bound to the local interface. Comment this line to listen to all interfaces. - Azure-specific: Make sure you create an entry endpoint so that external traffic can reach the MongoDB VM. You can use any port for the outside, and just bind it to 27017 internally. From a convention standpoint, it makes sense to use 27017 both externally and internally, since this is the default MongoDB port.
source to share
The port that mongodb is using is not open for external access. One way to access it from the client is to open an ssh tunnel. The default port for mongodb is 27017: ssh -f -L 27017 :: 27017
More on ssh tunneling here: http://blog.trackets.com/2014/05/17/ssh-tunnel-local-and-remote-port-forwarding-explained-with-examples.html
source to share