---
title: "Deploy Metabase HA"
description: "Metabase HA: replicated BI dashboards behind a load balancer."
category: "Storage"
url: https://railway.com/deploy/metabase-ha
---

# Deploy Metabase HA

Metabase HA: replicated BI dashboards behind a load balancer.

**[Deploy Metabase HA on Railway](https://railway.com/template/metabase-ha)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/metabase-ha/manifest.json

- **Creator:** Rakit
- **Category:** Storage
- **Total deploys:** 1

## Template content

### postgres https://devicons.railway.app/postgres

- **Source:** codestorm-official/metabase-ha

### metabase-1 https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/metabase.svg

- **Source:** codestorm-official/metabase-ha

### metabase-2 https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/metabase.svg

- **Source:** codestorm-official/metabase-ha

### proxy https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/caddy.svg

- **Source:** codestorm-official/metabase-ha
- **Public domain:** Yes

## Documentation

# Deploy and Host Metabase HA on Railway

A 2-node Metabase cluster behind a load balancer with a shared PostgreSQL application database. Built for production BI workloads that need high-availability dashboards and analytics.

## About Hosting

Metabase HA deploys two stateless Metabase instances behind a Caddy load balancer on Railway's private network. Both instances connect to a shared PostgreSQL database that stores all Metabase metadata — users, dashboards, questions, permissions, and settings. Since Metabase is stateless, any instance can serve any request, and the load balancer distributes traffic with health checks. If one instance goes down, the other continues serving without interruption. The Caddy proxy provides a single public HTTPS endpoint with automatic failover. PostgreSQL persists all application data on a volume. Metabase listens on port 3000 (Jetty) and ignores Railway's injected PORT. The health check at `/api/health` returns 200 only after migrations complete and the web server is ready.

## Common Use Cases

- **Business intelligence dashboards** — team analytics with high availability
- **Embedded analytics** — customer-facing dashboards in SaaS products
- **SQL exploration** — ad-hoc queries across multiple data sources
- **Scheduled reports** — automated email reports and alerts
- **Data democratization** — self-service analytics for non-technical teams
- **Executive dashboards** — real-time KPI monitoring

## Dependencies for

- **Metabase v0.65.7** — official `metabase/metabase:v0.65.7` image (831 MB)
- **PostgreSQL 16** — official `postgres:16` image (application database)
- **Caddy 2** — `caddy:2-alpine` for load balancing
- **Railway volumes** — one for PostgreSQL data
- **Railway private networking** — IPv6 inter-service communication

### Implementation Details

Metabase is stateless — all durable state lives in PostgreSQL. The load balancer distributes requests across instances using round-robin with health checks. Session affinity is not required because Metabase stores sessions in the database.

**Deployment timeline — please be patient.** First boot runs Metabase's database migrations, which take 2–4 minutes:

| Phase | Duration | What happens |
| --- | --- | --- |
| Postgres init | 0–1 min | Volume prepared, application database created |
| metabase-1 migrations | 2–4 min | Liquibase applies the full changelog — `/api/health` returns 503 and the proxy shows 502 until it finishes. **Do not redeploy during this window**: a killed migration can leave a lock that hangs later boots |
| metabase-2 boot | ~1 min | Schema already exists, starts quickly |
| Proxy routing | immediate | Caddy marks upstreams healthy and starts serving |

Deploy the instances one at a time on the first deploy (postgres → metabase-1 → wait healthy → metabase-2 → proxy): booting both instances simultaneously against a fresh database makes them fight over the migration lock. Later redeploys are safe to run together.

**Default credentials:** Metabase has no default admin — the setup wizard creates the first admin on first boot. PostgreSQL credentials are auto-generated at deploy time and shared between services via Railway variable references, so no manual setup is required.

**Accessing the dashboard:**

1. Open the public domain assigned to the `proxy` service
2. Complete the setup wizard (create admin account)
3. Connect your data sources under Admin → Databases

**Querying Metabase via its REST API:**

```bash
# Cluster health (through the proxy, from anywhere)
curl https://<proxy-domain>/api/health

# Example: list dashboards with an API session token
curl -H "X-Metabase-Session: <session-id>" https://<proxy-domain>/api/dashboard
```

**Ports:**

| Port | Purpose | Exposure |
| --- | --- | --- |
| 3000 | Metabase (Jetty) | Private (behind proxy) |
| 5432 | PostgreSQL | Private (app DB only) |
| 8080 | Caddy proxy | Public (via Railway domain) |

**Volume:** One volume for PostgreSQL at `/var/lib/postgresql/data`.

**Health check:** `GET /api/health` returns 200 only after migrations complete.

**Note on first boot:** Metabase runs database migrations on first start. This can take 2-4 minutes. The health check will return 503 until ready. Do not restart during migration.

## Comparison with Alternatives

| Feature | Metabase HA (this template) | Single Metabase | Tableau | Looker | Apache Superset |
| --- | --- | --- | --- | --- | --- |
| Cost (self-hosted) | ⚠️ 4 services | ✅ 1 service | ❌ Expensive | ❌ Expensive | ✅ Free |
| Setup complexity | ⚠️ 4 services | ✅ 1 service | ❌ Complex | ❌ Complex | ⚠️ Moderate |
| SQL + No-code | ✅ Both | ✅ Both | ✅ Both | ✅ Both | ✅ Both |
| Self-service analytics | ✅ Excellent | ✅ Excellent | ✅ Good | ✅ Good | ⚠️ Moderate |
| Fault tolerance | ✅ 2 instances | ❌ | ❌ Managed | ❌ Managed | ⚠️ Manual |
| Embedded analytics | ✅ Pro/Enterprise | ✅ Pro/Enterprise | ✅ | ✅ | ⚠️ Limited |
| Data source support | ✅ 20+ | ✅ 20+ | ✅ Many | ✅ Many | ✅ Many |
| License | ✅ AGPL (OSS) | ✅ AGPL | ❌ Proprietary | ❌ Proprietary | ✅ Apache 2.0 |

## Security Considerations

- **Encryption key**: `MB_ENCRYPTION_SECRET_KEY` encrypts stored database credentials. Generate once and never change — rotating it breaks decryption.
- **Session signing**: `MB_SESSION_SECRET_KEY` signs session tokens. In an HA deployment sessions are shared through the application database, so both instances must use the same signing secret — without it, sessions are stored unsigned and anyone with database access can impersonate any user.
- **Admin password**: Set during setup wizard. No default admin account.
- **Database credentials**: Use a dedicated PostgreSQL user with limited privileges (not superuser).
- **Network access**: Metabase instances are private (behind proxy). PostgreSQL is private (app DB only).
- **Volume encryption**: Railway volumes are encrypted at rest.
- **No public Metabase port**: Only the Caddy proxy is public.

## Why Deploy Metabase 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 Metabase 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.

Two Metabase instances with a shared PostgreSQL database and a load-balancing proxy — no single point of failure for the BI layer. Set the encryption key and deploy.

## Similar templates

- [RustFS | (Just Updated) S3 Object Store, Public URL and Keys Set](https://railway.com/deploy/rustfs-or-just-updated-s3-object-store-p) — S3-compatible object store, keys and public URL preset, volume kept
- [TimescaleDB](https://railway.com/deploy/timescaledb-railway-template) — Time-series analytics on PostgreSQL: fast, familiar, scalable.
- [Neo4j 2026.10 Community](https://railway.com/deploy/neo4j-202610-community) — Neo4j graph database with APOC, Browser, Bolt TCP proxy and a volume

Open this page in a browser: https://railway.com/deploy/metabase-ha
