Toto pro mě problém vyřešilo:
var options = {
server: {
socketOptions: {
keepAlive: 300000, connectTimeoutMS: 30000
}
},
replset: {
socketOptions: {
keepAlive: 300000,
connectTimeoutMS : 30000
}
}
};
Pak to vložte sem:
if(process.env.MONGODB_URI) {
mongoose.connect(process.env.MONGODB_URI, options);
} else {
// Connect to local database
}