title: mongoose.connect in my express app have name: MongoParserError , message: 'URI malformed, cannot be parsed'
body: <pre><code>mongoose
      .connect(db,{ useNewUrlParser: true}) 
      .then(() =&gt; console.log("MongoDB conected ..."))
      .catch(err =&gt; console.log(err));
  </code></pre>
  
  <p><i>Above mentioned is my code where 'db' is my database URI provided by mLab </i></p>
  
  <p>When I write run the express code its catches the error and gives out specific err message as:</p>
  
  <blockquote>
    <p>URI malformed, cannot be parsed</p>
  </blockquote>
  
  <pre><code>{ MongoError: URI malformed, cannot be parsed
      at parseConnectionString (/Users/dibs/Desktop/mern-ex/node_modules/mongodb-core/lib/uri_parser.js:207:21)
      at connect (/Users/dibs/Desktop/mern-ex/node_modules/mongodb/lib/operations/mongo_client_ops.js:179:3)
      at connectOp (/Users/dibs/Desktop/mern-ex/node_modules/mongodb/lib/operations/mongo_client_ops.js:283:3)
      at executeOperation (/Users/dibs/Desktop/mern-ex/node_modules/mongodb/lib/utils.js:420:24)
      at MongoClient.connect (/Users/dibs/Desktop/mern-ex/node_modules/mongodb/lib/mongo_client.js:168:10)
      at Promise (/Users/dibs/Desktop/mern-ex/node_modules/mongoose/lib/connection.js:487:12)
      at Promise (&lt;anonymous&gt;)
      at NativeConnection.Connection.openUri (/Users/dibs/Desktop/mern-ex/node_modules/mongoose/lib/connection.js:484:19)
      at Mongoose.connect (/Users/dibs/Desktop/mern-ex/node_modules/mongoose/lib/index.js:229:15)
      at Object.&lt;anonymous&gt; (/Users/dibs/Desktop/mern-ex/server.js:20:6)
      at Module._compile (module.js:569:30)
      at Object.Module._extensions..js (module.js:580:10)
      at Module.load (module.js:503:32)
      at tryModuleLoad (module.js:466:12)
      at Function.Module._load (module.js:458:3)
      at Function.Module.runMain (module.js:605:10)
    name: 'MongoParseError',
    message: 'URI malformed, cannot be parsed',
    [Symbol(mongoErrorContextSymbol)]: {} }
  </code></pre>