title: Connecting to remote mongo server
body: <p>I am having problems in connecting to an instance of mongodb running on a remote server. lets say i have a server <strong>A</strong> (123.45.67:27017) that runs a mongo db on port 27017. Then when i try to connect from my own machine <strong>B</strong> by typing:</p>
  
  <p><code>B$: mongo A:27017</code> </p>
  
  <p>I will get an error </p>
  
  <p><code>Failed to connect to A:27017, in(checking socket for error after poll), reason: Connection refused</code></p>
  
  <p>What i did for trouble shooting: </p>
  
  <ol>
  <li>Made sure the port 27017 is open on the server A. Tested using nc -l 27017 and it works - i can type over to B. </li>
  <li>Connected successfully to the database by using a ssh tunnel to bind the 27017 port to localhost: <code>ssh -f -L 27017:localhost:27017 myUserName@A sleep 10; mongo localhost:27017</code>  </li>
  </ol>
  
  <p>So in short, the database runs, the port is open and i can use the database when bound to local port. Anyone can help?</p>