$linuxjunkies
>

How to Install RabbitMQ on Linux

Install RabbitMQ on Debian, Ubuntu, Fedora, Rocky, and Arch using official repos, enable the management UI, create users, and test a live queue.

IntermediateUbuntuDebianFedoraArch9 min readUpdated June 7, 2026

Before you start

  • A Linux server with sudo or root access
  • curl installed for downloading repository setup scripts
  • A resolvable hostname (check with 'hostname -f')
  • Ports 5672 and 15672 not already in use

RabbitMQ is a production-grade message broker used everywhere from microservices to IoT pipelines. The official packages from Team RabbitMQ's own apt/dnf repositories are always fresher and better supported than what distro maintainers ship, so this guide uses those. You will end the walkthrough with a running broker, the management web UI enabled, a dedicated vhost and user, and a test message round-tripped through the CLI.

Before You Start

RabbitMQ requires a compatible Erlang/OTP installation. The safe approach is to pull both from the same official repository so the versions are guaranteed to be compatible. Mixing a distro Erlang with an official RabbitMQ package is a common source of silent failures.

Step 1 — Add the Official Repositories

Debian and Ubuntu

Team RabbitMQ publishes a shell-based setup script that registers both the Erlang and RabbitMQ repositories and imports their signing keys. Review it before piping to bash — the current URL is on rabbitmq.com.

sudo apt-get install -y curl gnupg apt-transport-https
# Add Erlang repository (Cloudsmith mirror maintained by Team RabbitMQ)
curl -1sLf 'https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/setup.deb.sh' \
  | sudo -E bash
# Add RabbitMQ repository
curl -1sLf 'https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/setup.deb.sh' \
  | sudo -E bash
sudo apt-get update
sudo apt-get 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-get install -y rabbitmq-server

Fedora and RHEL / Rocky Linux

Use the equivalent Cloudsmith setup scripts for RPM-based systems. On RHEL 9 / Rocky 9 you may also need to enable the codeready-builder or crb repository first for some Erlang dependencies.

# Rocky/RHEL 9 — enable CRB (skip on Fedora)
sudo dnf config-manager --set-enabled crb
curl -1sLf 'https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/setup.rpm.sh' \
  | sudo -E bash
curl -1sLf 'https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/setup.rpm.sh' \
  | sudo -E bash
sudo dnf install -y erlang rabbitmq-server

Arch Linux

RabbitMQ and Erlang are both in the official extra repository on Arch and are usually kept current.

sudo pacman -Syu rabbitmq

Step 2 — Enable and Start the Service

RabbitMQ ships a proper systemd unit. Enable it so it starts on boot, then start it now.

sudo systemctl enable --now rabbitmq-server

Confirm it is running:

sudo systemctl status rabbitmq-server

You should see active (running) in the output. If it failed, check journalctl -u rabbitmq-server -n 50 first — the most common cause is a hostname that does not resolve to itself, which breaks Erlang's node discovery.

Step 3 — Enable the Management Plugin

The management plugin adds a web UI on port 15672 and the HTTP API. It is bundled with RabbitMQ; you just need to activate it.

sudo rabbitmq-plugins enable rabbitmq_management

Restart the broker to load the plugin:

sudo systemctl restart rabbitmq-server

Step 4 — Open the Firewall

RabbitMQ uses two ports you need to allow: 5672 (AMQP) and 15672 (management UI). Adjust based on which firewall tool your distro uses.

firewalld (Fedora / RHEL / Rocky)

sudo firewall-cmd --permanent --add-port=5672/tcp
sudo firewall-cmd --permanent --add-port=15672/tcp
sudo firewall-cmd --reload

ufw (Ubuntu / Debian)

sudo ufw allow 5672/tcp
sudo ufw allow 15672/tcp

nftables (Arch or manual setup)

sudo nft add rule inet filter input tcp dport { 5672, 15672 } accept

If this is a production server, restrict these ports to specific source IPs rather than opening them to the world.

Step 5 — Create an Admin User and Remove the Default

The default guest account can only connect from localhost — that is intentional. Create a named admin user, grant it full privileges, then optionally delete guest.

sudo rabbitmqctl add_user mqadmin 'StrongPassw0rd!'
sudo rabbitmqctl set_user_tags mqadmin administrator
# Grant full access to all vhosts (the default vhost is named /)
sudo rabbitmqctl set_permissions -p / mqadmin ".*" ".*" ".*"
# Optional but recommended on production
sudo rabbitmqctl delete_user guest

Navigate to http://<server-ip>:15672 in a browser and log in with your new credentials. You should land on the management overview dashboard.

Step 6 — Create a Virtual Host and an Application User

Virtual hosts are RabbitMQ's namespace isolation. Give your application its own vhost and a least-privilege user rather than using the root / vhost for everything.

sudo rabbitmqctl add_vhost myapp
sudo rabbitmqctl add_user myapp_user 'AppPassw0rd!'
sudo rabbitmqctl set_permissions -p myapp myapp_user ".*" ".*" ".*"

The three ".*" patterns cover configure, write, and read permissions respectively on every resource in the vhost.

Step 7 — Publish and Consume a Test Message with rabbitmqadmin

rabbitmqadmin is a Python CLI that talks to the HTTP API. Download it directly from your own broker instance.

curl -u mqadmin:'StrongPassw0rd!' http://localhost:15672/cli/rabbitmqadmin \
  -o rabbitmqadmin
chmod +x rabbitmqadmin

Declare a durable queue in your new vhost:

./rabbitmqadmin -u mqadmin -p 'StrongPassw0rd!' -V myapp \
  declare queue name=test-queue durable=true

Publish a message to the default exchange, routing it to the queue by name:

./rabbitmqadmin -u mqadmin -p 'StrongPassw0rd!' -V myapp \
  publish exchange=amq.default routing_key=test-queue \
  payload="hello from rabbitmqadmin"

Consume (and acknowledge) that message:

./rabbitmqadmin -u mqadmin -p 'StrongPassw0rd!' -V myapp \
  get queue=test-queue ack_mode=ack_requeue_false

You will see output similar to:

# output will vary
+-------------+----------+---------------+-------------------------+---------------+------------------+-------------+
| routing_key | exchange | message_count |          payload        | payload_bytes | payload_encoding | redelivered |
+-------------+----------+---------------+-------------------------+---------------+------------------+-------------+
| test-queue  |          | 0             | hello from rabbitmqadmin|            24 | string           | False       |
+-------------+----------+---------------+-------------------------+---------------+------------------+-------------+

Verification

Run a quick broker health check using the built-in tool:

sudo rabbitmq-diagnostics ping
sudo rabbitmqctl list_queues -p myapp name messages consumers

Both commands should return without errors and show your queue (with 0 messages after the consume step).

Troubleshooting

  • Service fails to start — "nodedown" in logs: RabbitMQ's Erlang node name is tied to the hostname. Run hostname and ensure that name resolves in /etc/hosts. A line like 127.0.1.1 myhostname is usually enough.
  • Management UI unreachable on port 15672: Confirm the plugin is active with sudo rabbitmq-plugins list | grep management. A line starting with [E*] means it is enabled and running.
  • Permission denied on rabbitmqctl: rabbitmqctl uses an Erlang cookie at /var/lib/rabbitmq/.erlang.cookie. Running it with sudo ensures the cookie is readable. Avoid running it as a non-root user without explicitly copying the cookie.
  • Version mismatch between Erlang and RabbitMQ: Check the official Erlang compatibility matrix. On Debian/Ubuntu, run dpkg -l | grep erlang-base and compare against what RabbitMQ requires.
tested on:Ubuntu 24.04Debian 12Rocky 9Arch rolling

Frequently asked questions

Why not just install RabbitMQ from the default distro repository?
Distro repositories often lag months behind upstream releases and may pair RabbitMQ with an incompatible Erlang version. The official Cloudsmith repositories always provide tested, compatible pairings and receive security updates promptly.
Can I access the management UI over HTTPS?
Yes. You need to configure TLS certificates in /etc/rabbitmq/rabbitmq.conf using the management.ssl.* options, or place a reverse proxy like Nginx or Caddy in front of port 15672. The reverse proxy approach is simpler for most setups.
What is the difference between a vhost and a queue?
A virtual host is an isolated namespace inside one broker — it has its own exchanges, queues, bindings, and permissions. A queue is a buffer for messages inside a vhost. Think of vhosts like database schemas and queues like tables.
How do I make RabbitMQ survive server reboots with messages intact?
Declare your queues with durable=true and publish messages with delivery_mode=2 (persistent). Durable queues survive a broker restart; persistent messages are written to disk so they are not lost if the broker stops before they are consumed.
rabbitmqctl commands are slow or time out — what is wrong?
This almost always means the Erlang node name does not match the server's hostname, so the CLI tool cannot reach the running broker node. Verify that the output of 'hostname' resolves in /etc/hosts, then restart rabbitmq-server.

Related guides