Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongooseError: You can not `mongoose.connect()` multiple times while connected

I am getting the below error when trying to connect using moongoose.

MongooseError: You can not mongoose.connect() multiple times while connected.

throw new _mongoose.Error('You can not mongoose.connect() multiple times while connected.'); ^ MongooseError: You can not mongoose.connect() multiple times while connected. at new MongooseError (/node_modules/mongoose/lib/error/mongooseError.js:10:11)

Please help me find the cause for this and how to prevent it

like image 841
Thomas Joseph Avatar asked Jun 25 '19 18:06

Thomas Joseph


1 Answers

In mongoose version 5.6.1 the check was added https://github.com/Automattic/mongoose/pull/7905

Revert to an older version for a quick fix.

like image 156
iamdimitar Avatar answered Oct 02 '22 22:10

iamdimitar