title: Connect to remote mongodb server with java
body: <p>I'm trying to connect to a remote mongodb instance, but it keeps throwing an error.</p>
  
  <p>Java code:</p>
  
  <pre><code>Mongo mongo = new Mongo("172.234.52.24");
  DB db = mongo.getDB("myDB");
  collection = db.getCollection("myCollection");
  </code></pre>
  
  <p>But I keep getting the following exception:</p>
  
  <pre><code>java.io.IOException: couldn't connect to [/172.234.52.24:27017] bc:java.net.ConnectException: Connection refused
  </code></pre>
  
  <p>Is there something else I have to do? Set username/password when I try to access the database or change some permissions on the mongo side? Its just the normal mongo install on a ubuntu server, no added configuration or permissions.</p>
  
  <p>ADDITIONAL INFORMATION: mongo 172.234.52.24:8888 doesn't work either, says exception: connect failed. I can ping the other host, and know mongo is running on it.</p>
  
  <p>Any ideas? 
  Thanks!</p>