Skip to main content

Connections in MongoDB Atlas Clusters

Explaining Atlas connections and where to see them

Written by Mary Gorman


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

Where do Atlas connections come from? 

  • Heartbeats and replication between the nodes (20-25 connections)

  • Agent connections (backup, monitoring, and automation agents)

  • Driver connections

  • Application connections

Note: Some existing connections will automatically exist when you first deploy your Atlas cluster for the monitoring and administrative tasks. This is expected behavior and ensures your cluster(s) are healthy.
​


How can I see the connections to my cluster?

For all MongoDB Atlas clusters:

  • The Atlas UI displays the total active connections to each cluster (for the previous 6 hours) and the connection limit.
    - Replica sets show the number of active connections to the primary.
    - Sharded clusters show the sum of all active connections to each primary in the cluster.
    ​

  • The METRICS tab on your Atlas cluster displays the active connections for the chosen date/time range;
    ​

For M10+ Instances:

  • The Real-Time Performance Panel displays the number of current connections to the machine hosting MongoDB and the number of inbound and outbound bytes as reported by mongostat.

  • Connect to your cluster via the command line tools (see Connect with Mongostat)

  • Download your MongoDB logs to examine when connections are opened and closed (click “...” on your cluster and selecting “Download Logs”). 

  • Run the following script (via the mongo shell) to generate a basic list of all active client connections (not available for free tier (M0), M2 and M5 Instances):

db.currentOp(true).inprog.forEach( function(op) { if(op.active = true && op.client != undefined) { var miniOp = { client : op.client, description : op.desc }; printjson(miniOp);}  } );


See also the article Closing Connections in MongoDB Atlas Clusters for an explanation of how to close connections to a MongoDB Atlas cluster.

Did this answer your question?