How to disable RabbitMQ default tcp listening port - 5672
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
RabbitMQ is a widely utilized open-source message-broker software that facilitates asynchronous communication and implements the Advanced Message Queuing Protocol (AMQP). By default, it listens on TCP port 5672 for such AMQP connections. However, there may be scenarios—such as security policies, specific application needs, or environment setups—where you need to disable this default port. In this article, we will explore how you can achieve this modification through the RabbitMQ configuration.
Understanding RabbitMQ Configuration
Configuring RabbitMQ involves manipulating its configuration file, which could be rabbitmq.conf on newer installations or the older rabbitmq.config format. The location of this configuration file might vary based on the operating system and the method of installation (package manager, direct download, etc.).
Disabling the Default Port
To disable the default TCP listening port (5672), you should adjust the listeners for AMQP within the RabbitMQ configuration file (rabbitmq.conf). Essentially, you must specify that no listeners should be available for AMQP or you can change the default listening port to a different one if the service still needs to be accessible.
Here’s how it can be achieved:
After making this change, it’s necessary to restart RabbitMQ for the changes to take effect. This can typically be done using your system’s service management (like systemctl restart rabbitmq-server on systemd-based systems).
Alternative Configuration: Different Port or Interface
If you need RabbitMQ to listen for AMQP connections on a different port or network interface, configure it like this:
Security Considerations
When disabling a default port or redirecting traffic to a different port or interface, you must also consider possible security implications:
- Ensure firewall rules are updated accordingly to prevent unauthorized access.
- Consider using TLS/SSL for encrypting traffic, especially when engaging with interfaces exposed to public networks.
- Regularly update and patch RabbitMQ and its dependencies to mitigate vulnerabilities.
Testing Configuration Changes
After configuration changes, always ensure that RabbitMQ behaves as expected:
- Check the RabbitMQ service status.
- Validate the listening ports using tools like
netstatorss. - Test the connectivity from a client to see if it still functions appropriately.
You can use the following command to check the listening ports:
If the configurations are correctly set, this command should not return any result for port 5672, indicating that RabbitMQ no longer listens on the default port.
Summary Table
Here is a summary of key actions and points:
| Action | Description | Command/Code Example |
| Disabling the Default Port | Stop RabbitMQ from listening on port 5672 | listeners.tcp.default = none |
| Changing the Listening Port | Set RabbitMQ to listen on a different port | listeners.tcp.default = 5673 |
| Specify Listening Interface and Port | Define a specific interface and port | listeners.tcp.1 = 192.168.1.5:5672 |
| Restart RabbitMQ After Changes | Make configuration changes effective | systemctl restart rabbitmq-server |
| Verify No Listening on Default Port | Check RabbitMQ is not listening on port 5672 | sudo ss -tulwn | grep 5672 |
Additional Resources
For readers interested in further particulars about RabbitMQ’s management and configuration:
- RabbitMQ’s official documentation offers a comprehensive guide: RabbitMQ Documentation
- For security best practices, refer to the Security section in the official documentation.
By adhering to the steps outlined in this article, you can effectively manage how RabbitMQ listens for AMQP connections, enhancing both the flexibility and security of your message broker setups.

