Plaksel
Plaksel

Reputation: 160

Incomplete key value pair for option remote mongodb

I'm trying to deploy my local node mongoDB app to Heroku. Everything is working fine on my local machine, no errors.

First thing I'm trying to do is to connect to a database on mlab. It seen very straight forward but I get this error:

err { MongoParseError: Incomplete key value pair for option
  name: 'MongoParseError',
  message: 'Incomplete key value pair for option',
  [Symbol(mongoErrorContextSymbol)]: {} }

My code looks like this:

    var mongoose = require('mongoose');

    const options = {
            useNewUrlParser: true
          };

    mongoose.connect("mongodb://username:[email protected]:39251/nameodDB",options).then(
   ()=>{
      console.log("connected to mongoDB")},
   (err)=>{
       console.log("err",err);
 });

Upvotes: 0

Views: 8514

Answers (1)

chinyavadav
chinyavadav

Reputation: 37

MongoDB password needs to be URLEncoded if it consists of special characters like "@" which highlights the start of the host

Upvotes: 1

Related Questions