title: Getting 502 Bad Gateway: Registered endpoint failed to handle the request when tried to connect mongodb using node js in PCF platform
body: <p>I have <strong>mongodb</strong> in <strong>AWS EC2 instance</strong>.</p>
  
  <p>I am trying to connec to mongodb instance from nodejs server using <strong>mongoClient</strong>. My node application is deployed on PCF platform.</p>
  
  <p>When i try to connect to mongodb<br>
  it throws an error "<strong>502 Bad Gateway</strong>:</p>
  
  <p>Registered endpoint failed to handle the request". My node application is working fine, one the connection with mongodb is causing the problem.</p>
  
  <pre><code>conn_str += req.params.dbname;
  mongoClient.connect(conn_str, function(err, db) {
      if(err) {
          res.end(err);
      } else {
          res.end(db);
      }
  });
  </code></pre>
  
  <p>Help much appreciated.</p>