I am having problem connecting to MongoDB from NodeJS using following sample code. I tried running \"mongod\" with or without sudo but nodejs code still fail to connect. I a
Somebody on Github found a solution: Instead of writing:
Mongoose.connect(config.database.url);
Write:
Mongoose.connect(config.database.url, { keepAlive: true, reconnectTries: Number.MAX_VALUE, useMongoClient: true });
(Source https://github.com/Automattic/mongoose/issues/5399)