0
0
RabbitmqHow-ToBeginner ยท 3 min read

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 rabbitmqctl commands 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

CommandDescription
rabbitmqctl list_connectionsLists active connections with default columns
rabbitmqctl list_connections pid peer_address stateLists connections showing process ID, client IP, and state
Enable Management Pluginrabbitmq-plugins enable rabbitmq_management
Access Management UIOpen 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.