Search code examples
node.jsmongodbnodemonmongodb-atlas

Gracefully disconnecting to from mongodb atlas upon restarting via nodemon


The current application is in development phase and nodejs server is restarted everything any file changes. This lets mongoose reconnect to the MongoDB server.

I am the only one user to connect to remove MongoDB atlas by I don't know how its showing 5 connections are already opened. I don't know-how.

Is there any way to disconnect from MongoDB server before restarting of the application


Solution

  • I am the only one user to connect to remove MongoDB atlas by I don't know how its showing 5 connections are already opened.

    There are internal connections used by MongoDB for various purposes like replica set node communications.

    Is there any way to disconnect from MongoDB server before restarting of the application

    There surely must be but if you are concerned for Atlas having extra connections open, at this scale (5 connections) it is really not worthwhile worrying about it.