title: MongoDB connection error on AWS ec2 instance
body: <p>I have trying to connect to my mongo server on ec2 instance from my app hosted on elastic beanstalk.</p>
  
  <p>It worked when authorization was NOT enabled. I could connect through both local IP and public IP. </p>
  
  <p>Then I added users to the DB and enabled authorization in server. I could connect to the server using mongodb://user:password@ec2IP/27017 from any commandline interface. </p>
  
  <p>Using the same mongo URI from the elasticbeanstalk app I cannot connect to the mongodb server. This is the error I am getting - </p>
  
  <pre><code>MongoError: failed to connect to server [&lt;user-name-mongo-server&gt;:27017] on first connect [MongoError: getaddrinfo ENOTFOUND &lt;user-name-mongo-server&gt; &lt;user-name-mongo-server&gt;:27017
  </code></pre>
  
  <p>Any idea? Thanks in advance!</p>