Ubuntu – Cannot connect to mongodb instance on Azure

azuremongodbUbuntu

I have setup a mongodb server on Azure (on Ubuntu 15.04). The instance works and I can connect to mongodb when ssh'd into the machine by simply using 'mongo'.

However, when I try to connect from my computer directly, it does not work. My understanding was that it should because:

I have created a security exception on Azure:

rule

I have commented out the bindIp variable in the config file. I can confirm this with netstat -l, which outputs the line:

tcp 0 0 *:27017 *:* LISTEN

I have restarted the whole thing many times. I still get the same error message on the client:

  mongo ***.westeurope.cloudapp.azure.com
  MongoDB shell version: 2.6.10
  connecting to: ***.westeurope.cloudapp.azure.com/test
  2016-02-09T15:41:54.404+0100 Error: couldn't connect to server ***.westeurope.cloudapp.azure.com:27017 (40.113.138.104), connection    attempt failed at src/mongo/shell/mongo.js:148
  exception: connect failed

Best Answer

I made wrong assumptions about the internet connection of my company. Port 27017 is blocked. I solved the problem by using an open port instead.