title: MongoDB via Mlab - MongoError: Authentication failed
body: <p>I am creating a simple server using nodejs, expressJs and mongodb</p>
  
  <p>here is server.js</p>
  
  <pre><code>const express        = require('express');
  const MongoClient    = require('mongodb').MongoClient;
  const bodyParser     = require('body-parser');
  const db             = require('./config/db');
  const app            = express();
  const port = 8000;
  app.use(bodyParser.urlencoded({ extended: true }));
  MongoClient.connect(db.url, (err, database) =&gt; {
    if (err) return console.log(err)
    require('./app/routes')(app, database);
    app.listen(port, () =&gt; {
      console.log('We are live on ' + port);
    });               
  })
  </code></pre>
  
  <p>Note: database info are all okay, </p>
  
  <p>when i run node server.js , i get the following error :</p>
  
  <pre><code>    C:\Users\Bonge\Documents\Projects\movies_database&gt;node server.js
  { MongoError: Authentication failed.
      at Function.MongoError.create (C:\Users\Bonge\Documents\Projects\movies_database\node_modules\mongodb-core\lib\error.js:31:11)
      at C:\Users\Bonge\Documents\Projects\movies_database\node_modules\mongodb-core\lib\connection\pool.js:497:72
      at authenticateStragglers (C:\Users\Bonge\Documents\Projects\movies_database\node_modules\mongodb-core\lib\connection\pool.js:443:16)
      at Connection.messageHandler (C:\Users\Bonge\Documents\Projects\movies_database\node_modules\mongodb-core\lib\connection\pool.js:477:5)
      at Socket.&lt;anonymous&gt; (C:\Users\Bonge\Documents\Projects\movies_database\node_modules\mongodb-core\lib\connection\connection.js:331:22)
      at emitOne (events.js:116:13)
      at Socket.emit (events.js:211:7)
      at addChunk (_stream_readable.js:263:12)
      at readableAddChunk (_stream_readable.js:250:11)
      at Socket.Readable.push (_stream_readable.js:208:10)
    name: 'MongoError',
    message: 'Authentication failed.',
    ok: 0,
    errmsg: 'Authentication failed.',
    code: 18,
    codeName: 'AuthenticationFailed' }
  </code></pre>
  
  <p>what is wrong with my code?</p>