Deploy RabbitMQ HA
RabbitMQ HA cluster: 3-node quorum with failover, no ZooKeeper.
rabbitmq-3
Just deployed
/var/lib/rabbitmq
rabbitmq-2
Just deployed
/var/lib/rabbitmq
rabbitmq-1
Just deployed
/var/lib/rabbitmq
Deploy and Host RabbitMQ HA on Railway
A 3-node RabbitMQ cluster with quorum queues, automatic failover, and no ZooKeeper. Built for production workloads that need a message broker that survives node failures.
About Hosting
RabbitMQ HA deploys three clustered broker nodes on Railway's private IPv6 network. Quorum queues replicate data across all three nodes using Raft consensus, so a single node failure does not lose messages or stop processing. The cluster forms automatically: one node acts as the seed, and the other two join it on first boot. Subsequent deploys restart all nodes together, and each node recovers its own data from its persistent volume. The management UI runs on port 15672 with password authentication, and AMQP traffic is available on port 5672 via Railway's TCP proxy for external clients. Prometheus metrics are exposed on port 15692 for monitoring. No external coordination service is required — RabbitMQ 4 uses Khepri for metadata storage and quorum queues for data replication natively.
Common Use Cases
- Background job processing — Celery, Sidekiq, BullMQ, and n8n worker queues that must survive restarts
- Event-driven microservices — reliable message routing between services with dead-letter handling
- Task scheduling — delayed and retried jobs with per-message acknowledgements
- IoT data ingestion — high-throughput message buffering before database writes
- Integration middleware — connecting legacy systems with modern APIs via AMQP
Dependencies For
- RabbitMQ 4.3.8 — official
rabbitmq:4.3.8-managementimage - Railway volumes — one persistent volume per node at
/var/lib/rabbitmq(3 volumes total) - Railway private networking — IPv6-only inter-service communication
- Railway TCP proxy — for external AMQP client access
Implementation Details
Each node runs as a separate Railway service built from the same Dockerfile. The entrypoint handles Railway-specific requirements: stable node naming via RAILWAY_PRIVATE_DOMAIN, IPv6 Erlang distribution, shared Erlang cookie, and cgroup-aware resource limits. All three nodes share a single RABBITMQ_ERLANG_COOKIE_VALUE. The seed node forms the cluster; non-seed nodes wait for it on first boot. Quorum queues are the default queue type. Classic mirrored queues were removed in RabbitMQ 4.0.
Default credentials: Username is admin. Password is auto-generated via ${{secret(32)}} on first boot and logged in the deploy output. You can set RABBITMQ_DEFAULT_PASS before deploy to control it, or change the password later via the management UI — password changes persist across redeploys.
Accessing the management UI:
- Open the public domain assigned to
rabbitmq-1(port 15672) - Log in with username
adminand the generated password (check deploy logs on first boot) - Navigate to Overview → Nodes to confirm all 3 nodes are clustered
- Navigate to Queues to create and inspect queues
Sending and receiving a test message:
- In the management UI, go to Queues and Streams → Add a new queue
- Name it
test-queue, typeQuorum, click Add queue - Go to the queue → Publish message tab → enter a payload (e.g.,
{"hello":"railway"}) → click Publish message - Go to Get messages tab → click Get Message(s) → verify the payload is returned
- To test failover: stop
rabbitmq-2, publish another message, then startrabbitmq-2back — the message should still be available
Connecting external clients (AMQP):
Use the TCP proxy hostname and port assigned to rabbitmq-1 on port 5672. Connection string format:
amqp://admin:<password>@<tcp-proxy-host>:<tcp-proxy-port>
For internal Railway services, connect directly via private networking:
amqp://admin:<password>@rabbitmq-1.railway.internal:5672
Connecting via code (Python example):
import pika
conn = pika.BlockingConnection(
pika.ConnectionParameters(
host="rabbitmq-1.railway.internal",
port=5672,
credentials=pika.PlainCredentials("admin", "<password>")
)
)
ch = conn.channel()
ch.queue_declare(queue="test-queue", durable=True)
ch.basic_publish(exchange="", routing_key="test-queue", body="Hello from Railway")
print("Message sent")
conn.close()
Ports:
| Port | Purpose | Exposure |
|---|---|---|
| 5672 | AMQP 0-9-1 and AMQP 1.0 | Private + TCP proxy for external clients |
| 15672 | Management UI and HTTP API | Public domain (password-protected) |
| 15692 | Prometheus metrics | Private (Railway health check) |
| 4369 / 25672 | epmd and Erlang distribution | Private (cluster only) |
Volume: one volume per node at /var/lib/rabbitmq. Railway volumes are 1:1, which is why each cluster node is a separate service.
No Railway health check on cluster nodes: RabbitMQ serves nothing before its metadata store has a leader. On a cluster, that means it serves nothing until peers are reachable. Railway does not route *.railway.internal to a container whose deployment is still in its health-check window, so arming a health check on all three nodes deadlocks a whole-cluster restart. restartPolicyType: ALWAYS covers liveness instead. A crash-looping node is visible in the management UI's node list and in the rabbitmq_build_info series on /metrics.
Comparison with Alternatives
| Feature | RabbitMQ HA (this template) | Single RabbitMQ | Apache Kafka | NATS |
|---|---|---|---|---|
| Message durability | ✅ Quorum queues (Raft) | ❌ Single node | ✅ Replicated partitions | ✅ JetStream streams |
| Setup complexity | ⚠️ 3 services + shared cookie | ✅ 1 service | ❌ ZooKeeper/KRaft + brokers | ✅ Single binary |
| Protocol support | ✅ AMQP, MQTT, STOMP | ✅ AMQP, MQTT, STOMP | ⚠️ Kafka protocol only | ⚠️ NATS protocol (MQTT bridge) |
| Management UI | ✅ Built-in (port 15672) | ✅ Built-in | ⚠️ Third-party (Kafka UI) | ⚠️ Third-party (NATS Surveyor) |
| Memory footprint | ⚠️ 3 nodes (moderate) | ✅ Low | ❌ High (JVM) | ✅ Very low |
| Message routing | ✅ Exchanges, bindings, topics | ✅ Exchanges, bindings, topics | ⚠️ Topic-based only | ⚠️ Subject-based only |
| Dead-letter queues | ✅ Native | ✅ Native | ⚠️ Manual configuration | ⚠️ Manual configuration |
| Railway deploy count | 1 (this template) | 2+ | 1 | 0 |
Security Considerations
- Shared Erlang cookie:
RABBITMQ_ERLANG_COOKIE_VALUEmust be identical on all nodes and kept secret. It authenticates inter-node communication. Auto-generated via Railway's${{secret()}}— no manual input required. - Admin password: Auto-generated via
${{secret(32)}}on first boot. Password changes in the UI persist across redeploys. - Guest user deleted: The default
guest/guestaccount is removed on first boot. Only the configured admin user remains. - Management UI: Password-protected on port 15672. Do not expose without authentication. Consider restricting public access via Railway's private networking for internal-only brokers.
- AMQP port: Exposed via TCP proxy for external clients. Use TLS and strong credentials in production. Consider keeping AMQP internal-only if clients run on Railway.
- Volume encryption: Railway volumes are encrypted at rest. Ensure
RABBITMQ_DISK_FREE_LIMITis set to prevent disk exhaustion. - No health check: By design. Monitor via Prometheus metrics on port 15692 or the management UI.
Why Deploy RabbitMQ HA on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying RabbitMQ HA on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Three nodes with quorum queues, persistent volumes, and automatic clustering — no ZooKeeper, no manual Erlang configuration, no YAML. Just set the shared cookie and deploy.
Template Content
rabbitmq-3
codestorm-official/rabbitmq-harabbitmq-2
codestorm-official/rabbitmq-harabbitmq-1
codestorm-official/rabbitmq-ha