Mongoose unable to reconnect Mlab after restoring backup #4869

vir-c opened this Issue Jan 4, 2017 · 5 comments


None yet

3 participants

vir-c commented Jan 4, 2017 edited

I am not sure if this is a bug or a configuration mistake in my code or mlab issue.

Using heroku with mlab plugin for our app.
We are able to successfully reconnect if instance goes down and comes up.
But when we do a backup deployment from mlab dashboard, mongoose is not able to reconnect with mlab instance after backup is completed. We deploy our app again to successfully connect to server.
During backup 'close and 'disconnect' events are triggered.

Below is my code:

var models = require('../models');
/* To remove the warning coming on server start. */
mongoose.Promise = global.Promise;
//set model
var options={ 
	server: { 
		reconnectTries: Number.MAX_SAFE_INTEGER , 
		reconnectInterval: 10000, 
		socketOptions: { 
			keepAlive: 1, 
			connectTimeoutMS: 30000, 
			socketTimeoutMS: 20000 
mongoose.connect(db, options);

mongoose: 4.6.0
node: 6.9.1
mongoDB: 2.2.9


I'm not too familiar with mLab and have barely used Heroku, but how is the backup deployment done? Is it just a button you press or do you run a script? If it's a script, could you paste that script here?

vir-c commented Jan 6, 2017

@varunjayaraman we kind of press a button, mlab runs scripts that restore the backup data, we follow this.

varunjayaraman commented Jan 7, 2017 edited

Hm, it would probably be best to contact mlab about this. Without access to mLab's script, this is pretty difficult to debug, and they might have more information on why you can't reconnect.

Also, if you try connecting with the mongo shell after your backup, does it still fail? If so, it's definitely an mLab issue.


Does the mlab instance go down when you're restoring the backup? For how long?

Tbh I'd just restart the app when you're restoring a backup. It's not something you're going to be doing often I'd hope :)

vir-c commented Jan 12, 2017

@vkarpov15 I was looking forward for your reply
yes, the mlab instance does go down. The downtime depends upon the size of back up data, for a few documents it was about 3-5 mins.
certainly in-place restore is something we would use very rarely, so I guess restarting the app it is :)

@vkarpov15 vkarpov15 closed this Jan 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment