$ run as a normal user# run as root (or with sudo)
Know it before you install
Producers send messages to an exchange; bindings route them into queues; consumers read from queues and ack each message when done. A virtual host (vhost) is a separate space with its own exchanges, queues and rights — one per app or team. RabbitMQ runs on Erlang.
| Item | Value |
|---|---|
| Package | rabbitmq-server (needs a matching erlang) |
| Service | rabbitmq-server.service |
| Config | /etc/rabbitmq/rabbitmq.conf |
| Data / logs | /var/lib/rabbitmq/, /var/log/rabbitmq/ |
| Tools | rabbitmqctl, rabbitmq-diagnostics, rabbitmq-plugins, rabbitmq-queues |
| Ports | 5672 (AMQP), 5671 (AMQP over TLS), 15672 (management UI/API), 25672 + 4369 (cluster) |
Install on Ubuntu and Debian
The Ubuntu package is the quickest (a bit older version):
apt-get update
apt-get install -y rabbitmq-server
systemctl enable --now rabbitmq-server
rabbitmq-diagnostics status | head -20For the newest version, use the Team RabbitMQ repositories (Erlang + RabbitMQ) from the RabbitMQ install page for Debian/Ubuntu.
Install on RHEL, Rocky and Alma
RHEL has no RabbitMQ package. Add the repository file from the RabbitMQ install page for RPM systems (it provides a matching Erlang and RabbitMQ), then:
Or run the official container (any Linux with Docker or Podman), which is the fastest way to start:
docker run -d --name rabbitmq --hostname rabbit1 -p 127.0.0.1:5672:5672 -p 127.0.0.1:15672:15672 -v rabbitmq-data:/var/lib/rabbitmq rabbitmq:4-managementThe fixed --hostname matters: RabbitMQ stores data by node name.
First configuration: UI, users and vhosts
Turn on the management UI, remove the default guest user, and create an admin:
rabbitmq-plugins enable rabbitmq_management
rabbitmqctl add_user admin 'change-me-long-random'
rabbitmqctl set_user_tags admin administrator
rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
rabbitmqctl delete_user guestOne vhost and one user per app, with rights only there:
rabbitmqctl add_vhost shop
rabbitmqctl add_user shop-app 'another-long-password'
rabbitmqctl set_permissions -p shop shop-app "^shop\..*" "^shop\..*" "^shop\..*"
rabbitmqctl list_permissions -p shopThe three patterns are configure, write and read — here the app may only use exchanges and queues whose names start with shop..
Limits and listeners in the config file:
listeners.tcp.default = 5672
management.tcp.port = 15672
management.tcp.ip = 127.0.0.1
vm_memory_high_watermark.relative = 0.6
disk_free_limit.absolute = 2GB
default_queue_type = quorum
log.file.level = info| Setting | Why |
|---|---|
management.tcp.ip = 127.0.0.1 | The UI only through an SSH tunnel or Nginx with HTTPS. |
vm_memory_high_watermark.relative = 0.6 | Above 60 % RAM, RabbitMQ blocks publishers (instead of crashing). |
disk_free_limit.absolute = 2GB | Below 2 GB free disk, publishers are blocked — the server does not fill up. |
default_queue_type = quorum | New queues are replicated and safe in a cluster (RabbitMQ 3.13+/4). |
systemctl restart rabbitmq-server
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.0.1.0/24" port port="5672" protocol="tcp" accept'
firewall-cmd --reload
ssh -L 15672:127.0.0.1:15672 mq1Then open http://localhost:15672 and log in as admin.
Daily use: the commands and the real uses
rabbitmq-diagnostics check_running
rabbitmq-diagnostics alarms
rabbitmqctl list_queues -p shop name type messages messages_unacknowledged consumers
rabbitmqctl list_connections user peer_host state
rabbitmqctl list_consumers -p shop
rabbitmq-diagnostics memory_breakdown
rabbitmqctl purge_queue -p shop shop.emails
rabbitmqctl export_definitions /backup/rabbit-defs-$(date +%F).jsonWatch the numbers that matter: messages ready growing = workers too slow or down; unacked growing = workers stuck; consumers = 0 = nobody is reading.
Real uses at work:
- Background jobs: emails, PDFs, image processing, imports (Celery, Sidekiq-like workers, Spring AMQP).
- Decoupling services: the order service publishes, billing and shipping consume.
- Retry and dead-letter queues for messages that fail.
Make it safe
Security checklist:
- Delete
guest; one user per app; vhosts per app/team; permission patterns as small as possible. - Management UI on localhost or behind HTTPS + SSO; ports 5672/15672 never public.
- TLS (port 5671) when clients are on other networks.
- Memory and disk limits set; monitor alarms (Prometheus plugin
rabbitmq_prometheus, port 15692). - Quorum queues (3-node cluster) for important data; export definitions as a backup.
- Keep RabbitMQ and Erlang updated together (supported pairs only).
Update and remove
apt-get install --only-upgrade -y rabbitmq-server
dnf -y upgrade erlang rabbitmq-server
systemctl disable --now rabbitmq-server
apt-get purge -y rabbitmq-serverUpgrade one minor/major step at a time as the RabbitMQ upgrade guide says; enable all feature flags before a major upgrade (rabbitmqctl enable_feature_flag all).
Fix common problems
| Problem | Cause | Fix |
|---|---|---|
Publishers hang, logs say memory resource limit alarm set | RAM above the watermark. | Consumers must catch up; more RAM; check big queues; rabbitmq-diagnostics memory_breakdown. |
disk resource limit alarm set | Free disk below the limit. | Free disk space; purge or consume old queues. |
ACCESS_REFUSED - Login was refused | Wrong user/password, or guest from a remote host (only allowed on localhost). | Use your own user; check the password and vhost permissions. |
NOT_ALLOWED - vhost not found | The client uses another vhost. | Create it, or fix the vhost in the connection URL (amqp://user:pass@host:5672/shop). |
| Messages pile up | Workers are down or too slow. | list_consumers; scale workers; check their logs. |
| Node does not start after a host name change | RabbitMQ stores data by node name. | Keep a fixed host name (--hostname in containers); or reset the node. |
Cluster: Authentication failed (rejected by the remote node) | Erlang cookies differ. | Same /var/lib/rabbitmq/.erlang.cookie on all nodes (mode 400). |
Next steps
- Quick how-tos: Check a queue.
- Command page: rabbitmqctl.
- At work: Message broker. Event streaming instead of queues: Apache Kafka.
- A simple queue in memory: Redis. Run it in containers: Docker.
1What does it mean when "unacked" messages keep growing?
Workers took the messages but do not finish (ack) them — they are stuck or crashing.
2Why delete the guest user?
It is a known default account; your own named users with small rights are safer.