title: mongoose to mlab connection issues : UnhandledPromiseRejectionWarning: Unhandled promise rejection
body: <p><a href="https://i.stack.imgur.com/lgbFR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lgbFR.png" alt="enter image description here"></a><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>const express = require('express');
  const app = express();
  const mongoose = require('mongoose');
  require('./models/users');
  require('./services/passport');
  const authRoutes = require('./routes/authRoutes');
  const Keys = require('./config/dev');
  
  authRoutes(app);
  
  mongoose.connect(Keys.MONGOOSE_URI);
  
  const port = process.env.PORT || 5000;
  app.listen(port);</code></pre>
  </div>
  </div>
  </p>
  
  <p>I have a node express application and I trying to connect to <strong>mlab</strong> db using mongoose. I am getting following exception:</p>
  
  <blockquote>
    <p>UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): MongoNetworkError: failed to connect to server [ds111598.mlab.com:11598] otworkError: connect ECONNREFUSED 35.168.9.109:11598]</p>
  </blockquote>
  
  <p>Tech stack I am using:</p>
  
  <pre><code>"mongoose": "^4.11.1",
  node: 6.11.1
  npm: 4.6.1
  </code></pre>
  
  <p>I have tried using the latest mongoose version as well but still the same issue. I am stuck because of this. Can anybody help in this?</p>
  
  <p>Thanks</p>