On this page
- Why install from the RabbitMQ team repositories?
- How do you install RabbitMQ on Ubuntu or Debian?
- How do you install it on Rocky Linux 9 or AlmaLinux 9?
- Which accounts and vhosts should you create?
- How do you reach the management UI safely?
- How do you turn on TLS for AMQP clients?
- How do you cluster nodes that talk over public IPs?
- How do you upgrade and troubleshoot the broker?
- Questions
Why install from the RabbitMQ team repositories?
Use the project repositories because the distribution archives carry older 3.x releases that no longer receive fixes, while RabbitMQ 4 needs a recent Erlang/OTP that only those repositories pair with it reliably. The team publishes both packages side by side, so apt or dnf resolves a supported combination for you.
Plan the server around queues that stay short. RabbitMQ keeps message metadata in memory and pages bodies to disk, so 2 GB of RAM is a comfortable start for a few applications, and 4 GB gives room for quorum queues and the management plugin. Log in as a sudo user first (the first SSH session tutorial covers that) and give the machine a stable hostname, because the node name rabbit@hostname is stored inside the data directory.
sudo hostnamectl set-hostname mq1
echo "127.0.1.1 mq1" | sudo tee -a /etc/hosts
hostname -sHow do you install RabbitMQ on Ubuntu or Debian?
Import the signing key, write one source line per repository for your release, install the Erlang packages and then the server. The loop below reads the distribution name and codename from /etc/os-release, so the same lines work on Ubuntu 24.04, Ubuntu 22.04 and Debian 12.
sudo apt update
sudo apt install -y curl gnupg apt-transport-https
curl -1sLf "https://keys.openpgp.org/vks/v1/by-fingerprint/0A9AF2115F4687BD29803A206B73A36E6026DFCA" | sudo gpg --dearmor -o /usr/share/keyrings/com.rabbitmq.team.gpg
. /etc/os-release
for r in rabbitmq-erlang rabbitmq-server; do
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/com.rabbitmq.team.gpg] https://deb1.rabbitmq.com/$r/$ID/$VERSION_CODENAME $VERSION_CODENAME main"
done | sudo tee /etc/apt/sources.list.d/rabbitmq.list
sudo apt update
sudo apt install -y erlang-base erlang-asn1 erlang-crypto erlang-eldap erlang-ftp erlang-inets erlang-mnesia erlang-os-mon erlang-parsetools erlang-public-key erlang-runtime-tools erlang-snmp erlang-ssl erlang-syntax-tools erlang-tftp erlang-tools erlang-xmerl
sudo apt install -y rabbitmq-server --fix-missing
apt policy rabbitmq-serverOn Debian 13, run curl -sI https://deb1.rabbitmq.com/rabbitmq-server/debian/trixie/dists/trixie/Release before you start; if it does not answer with 200, use Debian 12 or Ubuntu 24.04 for the broker until trixie builds appear.
How do you install it on Rocky Linux 9 or AlmaLinux 9?
Create a repository file that points at the el9 builds, import the keys and install Erlang together with the server.
sudo rpm --import "https://github.com/rabbitmq/signing-keys/releases/download/3.0/rabbitmq-release-signing-key.asc"
sudo rpm --import "https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-erlang.E495BB49CC4BBE5B.key"
sudo rpm --import "https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-server.9F4587F226208342.key"
sudo tee /etc/yum.repos.d/rabbitmq.repo >/dev/null <<'EOF'
[rabbitmq-el9-erlang]
name=RabbitMQ Erlang el9
baseurl=https://yum1.rabbitmq.com/erlang/el/9/$basearch
gpgcheck=1
gpgkey=https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-erlang.E495BB49CC4BBE5B.key
repo_gpgcheck=1
enabled=1
[rabbitmq-el9-server]
name=RabbitMQ server el9
baseurl=https://yum1.rabbitmq.com/rabbitmq/el/9/noarch
gpgcheck=1
gpgkey=https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-server.9F4587F226208342.key
https://github.com/rabbitmq/signing-keys/releases/download/3.0/rabbitmq-release-signing-key.asc
repo_gpgcheck=1
enabled=1
EOF
sudo dnf install -y socat logrotate
sudo dnf install -y erlang rabbitmq-server
sudo systemctl enable --now rabbitmq-serverOn Ubuntu and Debian the service is enabled during installation. On every system, confirm the node answers:
sudo rabbitmq-diagnostics ping
sudo rabbitmq-diagnostics server_version
sudo ss -ltnp | grep -E '5672|25672|4369'Which accounts and vhosts should you create?
Create one administrator for yourself, one virtual host per application and one user per application with rights only on its vhost, then delete guest. The guest account can only log in from localhost, but removing it leaves nothing to guess.
sudo rabbitmqctl add_user ops 'Choose-A-Long-Passphrase'
sudo rabbitmqctl set_user_tags ops administrator
sudo rabbitmqctl add_vhost billing
sudo rabbitmqctl add_user billing_app 'Another-Long-Secret'
sudo rabbitmqctl set_permissions -p billing billing_app "^billing\..*" "^billing\..*" ".*"
sudo rabbitmqctl delete_user guest
sudo rabbitmqctl list_users
sudo rabbitmqctl list_permissions -p billingThe three permission patterns are configure, write and read. The example lets the application declare and publish to objects whose names start with billing. while reading from any queue in its own vhost. For durable work queues, declare them as quorum queues (argument x-queue-type set to quorum); classic mirrored queues are gone in version 4.
How do you reach the management UI safely?
Enable the plugin, keep its listener on the loopback address and open it through an SSH tunnel from your own computer.
sudo rabbitmq-plugins enable rabbitmq_management
echo "management.tcp.ip = 127.0.0.1" | sudo tee -a /etc/rabbitmq/rabbitmq.conf
sudo systemctl restart rabbitmq-server
# on your own computer
ssh -L 15672:127.0.0.1:15672 deploy@198.51.100.24Browse to http://localhost:15672 and sign in as ops. The same port serves the HTTP API, which makes a quick scripted health check easy:
curl -s -u ops:'Choose-A-Long-Passphrase' http://127.0.0.1:15672/api/overview | head -c 300How do you turn on TLS for AMQP clients?
Point RabbitMQ at a certificate and key, add a TLS listener on 5671 and bind the plain 5672 listener to localhost so outside clients must use encryption. A Let's Encrypt certificate for mq.example.net works well; see the Certbot guide for issuing it, then copy the files to a directory the rabbitmq user can read.
sudo install -d -o rabbitmq -g rabbitmq -m 750 /etc/rabbitmq/tls
sudo cp /etc/letsencrypt/live/mq.example.net/fullchain.pem /etc/rabbitmq/tls/
sudo cp /etc/letsencrypt/live/mq.example.net/privkey.pem /etc/rabbitmq/tls/
sudo chown rabbitmq:rabbitmq /etc/rabbitmq/tls/*.pem
sudo tee -a /etc/rabbitmq/rabbitmq.conf >/dev/null <<'EOF'
listeners.tcp.local = 127.0.0.1:5672
listeners.ssl.default = 5671
ssl_options.certfile = /etc/rabbitmq/tls/fullchain.pem
ssl_options.keyfile = /etc/rabbitmq/tls/privkey.pem
ssl_options.versions.1 = tlsv1.3
ssl_options.versions.2 = tlsv1.2
ssl_options.verify = verify_none
ssl_options.fail_if_no_peer_cert = false
EOF
sudo systemctl restart rabbitmq-server
openssl s_client -connect mq.example.net:5671 -brief </dev/nullAdd a Certbot deploy hook that repeats the copy and runs rabbitmqctl eval 'ssl:clear_pem_cache().' so renewals take effect without a restart.
How do you cluster nodes that talk over public IPs?
Give every node the same Erlang cookie, make each hostname resolve to its public address, open the inter-node ports only to the other nodes and join them one at a time. Our servers have no private network, so cluster traffic crosses public IPs; restrict it with firewall rules for peer addresses and, for sensitive payloads, carry it inside a WireGuard tunnel.
# on every node, /etc/hosts
198.51.100.24 mq1
198.51.100.25 mq2
198.51.100.26 mq3
# copy the cookie from mq1 to the others
sudo cat /var/lib/rabbitmq/.erlang.cookie
sudo systemctl stop rabbitmq-server
echo -n 'COOKIE-FROM-MQ1' | sudo tee /var/lib/rabbitmq/.erlang.cookie
sudo chmod 400 /var/lib/rabbitmq/.erlang.cookie
sudo chown rabbitmq:rabbitmq /var/lib/rabbitmq/.erlang.cookie
sudo systemctl start rabbitmq-server
# on mq2 and mq3
sudo rabbitmqctl stop_app
sudo rabbitmqctl reset
sudo rabbitmqctl join_cluster rabbit@mq1
sudo rabbitmqctl start_app
sudo rabbitmqctl cluster_statusFirewall rules per peer, shown for 198.51.100.25 (repeat for each node):
# Ubuntu and Debian
sudo ufw allow 22/tcp
sudo ufw allow 5671/tcp
for p in 4369 25672 35672:35682; do sudo ufw allow proto tcp from 198.51.100.25 to any port $p; done
sudo ufw enable
# Rocky and Alma
sudo firewall-cmd --permanent --add-port=5671/tcp
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="198.51.100.25" port port="4369" protocol="tcp" accept'
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="198.51.100.25" port port="25672" protocol="tcp" accept'
sudo firewall-cmd --reloadUse three nodes rather than two, because quorum queues need a majority to stay writable.
How do you upgrade and troubleshoot the broker?
Upgrade one node at a time with the normal package manager, after reading the release notes for required feature flags. Before a minor upgrade, enable all stable feature flags so the next version accepts the cluster state:
sudo rabbitmqctl enable_feature_flag all
sudo rabbitmq-diagnostics check_if_node_is_quorum_critical
sudo apt update && sudo apt install --only-upgrade rabbitmq-server
sudo rabbitmq-diagnostics status | head -20When something breaks, start with the logs in /var/log/rabbitmq/ and sudo journalctl -u rabbitmq-server -e. A node that will not start after a hostname change is looking for an old data directory under /var/lib/rabbitmq/mnesia/; set the hostname back. Publishers that hang usually hit a memory or disk alarm: sudo rabbitmq-diagnostics alarms shows it, and the fix is more consumers, shorter queues or a bigger plan. Keep backups of /etc/rabbitmq and export definitions with sudo rabbitmqctl export_definitions /root/defs.json.
Plans that fit this guide
Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.
Questions about RabbitMQ broker
Is 1 GB of RAM enough for RabbitMQ?
For a test broker with a handful of short queues, yes, but the default memory watermark is 60% of RAM, so a 1 GB server blocks publishers quickly. Start with 2 GB for production work.
Should my application use port 5672 or 5671?
Use 5671 (AMQPS) for anything that leaves the server. Plain 5672 is fine for an application on the same host connecting to 127.0.0.1.
How do I move queues and users to a new server?
Export definitions with rabbitmqctl export_definitions, import them on the new node with rabbitmqctl import_definitions, then drain the old queues by pointing consumers at both brokers for a while. The larger plan tutorial covers the server side.
Do quorum queues work on a single node?
They do, and they still give you safe on-disk replication logs, but replication only becomes real once three nodes join the cluster.
Why does rabbitmqctl say it cannot connect to the node?
The CLI needs the same Erlang cookie as the server. Run it with sudo so it reads the cookie in /var/lib/rabbitmq, and check that hostname -s matches the node name.