All Collections
Atlas Frequently Asked Questions
Closing Connections in MongoDB Atlas Clusters
Closing Connections in MongoDB Atlas Clusters

How to close connections in Atlas clusters

Mary Gorman avatar
Written by Mary Gorman
Updated over a week ago


MongoDB Atlas clusters have a connection limit per instance size. When the connection limit is exceeded, no new connections can be opened to the cluster.

To avoid hitting the maximum connections on your cluster, you can modify your cluster to scale up to a higher instance size or close existing connections.


How do I know when I am approaching maximum connections?

To monitor the connections to your Atlas cluster;

1. Use the connections % of configured limit alert which measures connections to MongoDB processes.  

2. Observe your connections from your cluster's metrics view;


How do I close existing connections? 

For M10+ clusters in your project:

For all MongoDB Atlas clusters in your project:

  • Restart the application which is currently making connections to your Atlas cluster.

  • Remove IP addresses from your IP whitelist for your project. Please note that removing the IP addresses from a given project will remove access to all clusters in that project.


How can I avoid reaching maximum connections?

1. Examine your database applications to ensure connections are being closed on exit.
2. Introduce any Connection Pooling options recommended by your driver.
3. Monitor connection alerts and scale up to a higher instance size for more connections if your user base requires this.


See also the article Connections in MongoDB Atlas Clusters for an explanation of Atlas connections and where to see them.

Did this answer your question?