Reputation: 160
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
Reputation: 37
MongoDB password needs to be URLEncoded if it consists of special characters like "@" which highlights the start of the host
Upvotes: 1