How to list MongoDB connections - client ip and port

24 January,2020 by Rambler

Question: How can I list client ip , port and connection ID of connections to MongoDB? I want to connect through the MongoDB command line and extract this information as I'm testing some HA failover scenarios. 

Answer: There's a few different ways to extract the MongoDB connection details - for example you can use netstat. But from the command line - this syntax will report the details required 


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


Example output - clientip:port clientid: 4668364 4668363 4668357

Read More on MongoDB

How to read MongoDB system log file

MongoDB cheatsheet

Author: Rambler (


Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.


Post a comment on How to list MongoDB connections - client ip and port