Port 5672 (AMQP)
Key facts
- Port
- 5672
- Protocols
- TCP
- Range
- Registered port, 1024-49151
- IANA service name
- amqp
IANA assigns ports in this range to services on request, under RFC 6335.
About port 5672
Port 5672 is the port of AMQP (Advanced Message Queuing Protocol), a protocol for passing messages between applications through queues. The best-known server that uses AMQP is RabbitMQ, and applications use it to pass tasks between parts of a system without waiting on each other.
In the IANA port registry, port 5672 is registered for the amqp service, and port 5671 is registered for the amqps service, for AMQP encrypted with TLS. According to the RabbitMQ documentation, AMQP clients connect on port 5672 without TLS and on port 5671 with TLS.
What port 5672 is used for
- Background tasks: a website puts tasks such as sending emails or processing images in a queue, and worker processes carry them out in the background.
- Communication between services: in systems built from several services, the services pass messages to each other through the queues.
- Data collection: systems that receive large numbers of events keep them in a queue until they are processed.
According to the RabbitMQ documentation, the browser-based management interface runs on port 15672, and the servers in a cluster communicate with each other on ports 4369 and 25672.
Port 5672 in the firewall
Port 5672 should be reachable only by the application servers that connect to the queues. When the application and RabbitMQ are on the same server, keep the port closed to incoming traffic from outside. When another server needs access:
- UFW:
ufw allow from 203.0.113.10 to any port 5672 proto tcp - firewalld:
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.10" port port="5672" protocol="tcp" accept'
When you restrict access to specific addresses, also delete any earlier rule that opened the port to everyone, or that general rule will keep allowing access from any address.
Allow the management interface on port 15672 only from administrators' addresses, and ports 4369 and 25672 only between the cluster servers.
Risks and security
A queue server holds application data, so protect it as you would a database:
- According to the RabbitMQ documentation, the guest user can connect by default only from the server itself. Keep this restriction, and create a separate user with a strong password for each application.
- Restrict each user to the virtual host and the permissions it needs.
- When the connection crosses a network that isn't private, use port 5671 with TLS.
- Restrict port 5672 and the management interface to known addresses.
Commands to check and configure
-
rabbitmq-diagnostics listenersShows all the ports RabbitMQ is listening on, and the protocol of each one.
-
rabbitmq-diagnostics statusShows the server status, including the version, memory and active ports.
-
ss -tlnp | grep ':5672 'Checks that the server is listening on port 5672, and on which address (requires root privileges).
-
rabbitmqctl add_user appuserCreates a new user named appuser. When no password is given in the command, it is prompted for separately.
-
rabbitmqctl set_permissions -p / appuser ".*" ".*" ".*"Gives the user appuser configure, write and read permissions on the default virtual host. In a real application, limit the permissions to the queues it needs.
-
ufw allow from 203.0.113.10 to any port 5672 proto tcpAllows access to port 5672 only from the specified IP address (UFW).
-
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.10" port port="5672" protocol="tcp" accept'Allows access to port 5672 in firewalld only from the specified IP address. Then run firewall-cmd --reload.
Port 5672 in the IANA registry
| Port | Protocol | Service | IANA registry description |
|---|---|---|---|
| 5672 | SCTP | amqp | AMQP |
| 5672 | TCP | amqp | AMQP |
| 5672 | UDP | amqp | AMQP |
Data source: IANA Service Name and Transport Protocol Port Number Registry (opens in a new tab)
Port 5672 FAQ
Why can't I connect remotely with the guest user?
According to the RabbitMQ documentation, the guest user is limited by default to connections from the server itself. Instead of removing the restriction, create a new user with rabbitmqctl add_user appuser and give it permissions with rabbitmqctl set_permissions.
What's the difference between port 5672 and port 5671?
Both ports are used for AMQP. On port 5672 the connection is not encrypted, and on port 5671 it is encrypted with TLS. When the application and the server are on the same private network you can use port 5672, and for connections over the internet use port 5671.
How do I open the RabbitMQ management interface?
Enable the plugin with rabbitmq-plugins enable rabbitmq_management, and browse to the server address on port 15672. Before that, allow the port in the firewall only from your own IP address.
Can I run RabbitMQ on a VPS?
Yes. RabbitMQ suits a VPS, on its own or together with the application that uses it. When they are on the same server, the connection uses the local address, and port 5672 stays closed to the internet.