In my cluster on Atlas, have a many connections in secondary nodes. How to list this connections?

When execute this command, list the current connections in primary node.

  (accumulator, connection) => {
    ipaddress = connection.client ? connection.client.split(":")[0] : "unknown";
    accumulator[ipaddress] = (accumulator[ipaddress] || 0) + 1;
    return accumulator;


But, I have 700 connection in replicaSet.Connections in Atlas Server


  1. Go to the command line tools

enter image description here

  1. Copy mongostat command under Set Up Diagnostics section

enter image description here

  1. Update password and add --discover option at the end

  2. Run it in any command-line tool

  3. You should be able to see the number of connections as below for all primary and secondaries enter image description here

| improve this answer | |

As mongo shell, this will print client IP:port, along with connection ID:

db.currentOp(true).inprog.forEach(function(d){if(d.client)print(d.client, d.connectionId)})

Note : Passing in true to db.currentOp() is equivalent to passing in a document of { "$all": true }. The following operations are equivalent:

db.currentOp( { "$all": true } )

For further ref here, here and here

| improve this answer | |
  • 1
    This solution, list only connections in primary node, – Afonso Rodrigues Sep 17 '19 at 12:35
  1. Connect to the secondary node directly from mongo shell

mongo secondary-node-address:port --ssl --authenticationDatabase admin --username uname --password xxx

  1. You should be directly connected to the secondary node, now run the db.currentOP(true), it will list down all secondary node's processes.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.