Skip to content

MongoError: pool is draining, new operations prohibited – How to fix?

MongoError: pool is draining, new operations prohibited – How to fix? You might face this error while doing some operations on a Mongo database.

mongoose.connect(url, {bufferMaxEntries: 0, reconnectTries: 5000, useNewUrlParser: true,useUnifiedTopology: true});

This error basically means that the connection that you established with the mongodb has already expired. To elaborate, you haven’t used connection pool with your mongo connection.

Advertisements

This error (pool is draining, new operations prohibited) might occur if you are using the official mongodb library for node js or mongoose. Please check if you are specifying pool size while establishing mongodb connection.

mongoose.connect(url, {poolSize: 10, bufferMaxEntries: 0, reconnectTries: 5000, useNewUrlParser: true,useUnifiedTopology: true});

Specifying pool size while connecting to mongo database, eliminates this error.

See also  Match a value with multiple fields using OR in MongoDB

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.