MongoLab recently updated the mongoDb version to 3.x. To try to reproduce the environment, i updated my local version of node.js to 4.x, mongodb to 3.x and mongoose to 3.8.
In my local environment i'm able to connect to mongoDb but in heroku i can't. The following error occurs :
fail to connect to mongodb for address mongodb://user:password@host:port/dbname
I suspect an older version of mongoose, or a bad connection way, but why it works on my local environment? Here how i connect node to mongoDb :
var uriString = process.env.MONGOLAB_URI || process.env.MONGOHQ_URL
mongoose.connect(uriString, function (err, res) {
if (err) {
console.log('fail to connect to mongodb for address ' + uriString);
} else {
console.log('Connection to mongodb ok');
}
});