How to List Connections in RabbitMQ: Commands and Examples
To list connections in RabbitMQ, use the
rabbitmqctl list_connections command in the terminal or the Management Plugin's web UI under the Connections tab. The CLI command shows active connections with details like client IP and state.Syntax
The basic command to list connections in RabbitMQ is rabbitmqctl list_connections [options]. You can specify which connection details to display by adding column names after the command.
For example, rabbitmqctl list_connections pid peer_address state lists the process ID, client IP address, and connection state.
bash
rabbitmqctl list_connections [column1] [column2] ...
Example
This example shows how to list all active connections with their process ID, client IP address, and connection state using the RabbitMQ CLI.
bash
rabbitmqctl list_connections pid peer_address state
Output
pid peer_address state
<0.1234.0> 192.168.1.10 running
<0.5678.0> 192.168.1.11 running
Common Pitfalls
- Running
rabbitmqctlcommands without proper permissions can cause errors; always run as a user with RabbitMQ control rights. - Not specifying columns shows a default set, which might not include all desired details.
- Using the Management Plugin requires it to be enabled; otherwise, the web UI won't show connections.
bash
Wrong: rabbitmqctl list_connections Right: rabbitmqctl list_connections pid peer_address state
Quick Reference
| Command | Description |
|---|---|
| rabbitmqctl list_connections | Lists active connections with default columns |
| rabbitmqctl list_connections pid peer_address state | Lists connections showing process ID, client IP, and state |
| Enable Management Plugin | rabbitmq-plugins enable rabbitmq_management |
| Access Management UI | Open http://localhost:15672 and go to Connections tab |
Key Takeaways
Use 'rabbitmqctl list_connections' to see active RabbitMQ connections from the command line.
Specify columns like 'pid', 'peer_address', and 'state' to get detailed connection info.
Ensure you have proper permissions to run RabbitMQ control commands.
Enable the Management Plugin to view connections via the web UI.
The Management UI provides a user-friendly way to monitor connections visually.