---
title: "Deploy Postgres HA"
description: "A Patroni based High Availability Postgres using etcd"
category: "Other"
url: https://railway.com/deploy/postgres-ha
---

# Deploy Postgres HA

A Patroni based High Availability Postgres using etcd

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

- **Creator:** Railway Templates
- **Category:** Other
- **Total deploys:** 3,130

## Template content

### etcd-2 https://upload.wikimedia.org/wikipedia/labs/5/53/Etcd_logo.png

- **Image:** ghcr.io/railwayapp-templates/postgres-ha/etcd:3

### Postgres-3 https://devicons.railway.app/postgres

- **Image:** ghcr.io/railwayapp-templates/postgres-ha/postgres-patroni:18

### Postgres-1 https://devicons.railway.app/postgres

- **Image:** ghcr.io/railwayapp-templates/postgres-ha/postgres-patroni:18

### Postgres HA https://upload.wikimedia.org/wikipedia/commons/a/ab/Haproxy-logo.png

- **Image:** ghcr.io/railwayapp-templates/postgres-ha/haproxy:3

### etcd-3 https://upload.wikimedia.org/wikipedia/labs/5/53/Etcd_logo.png

- **Image:** ghcr.io/railwayapp-templates/postgres-ha/etcd:3

### etcd-1 https://upload.wikimedia.org/wikipedia/labs/5/53/Etcd_logo.png

- **Image:** ghcr.io/railwayapp-templates/postgres-ha/etcd:3

### Postgres-2 https://devicons.railway.app/postgres

- **Image:** ghcr.io/railwayapp-templates/postgres-ha/postgres-patroni:18

## Documentation

# Deploy and Host Postgres HA on Railway

Patroni based High Availability system for Postgres

## About Hosting Postgres HA

Replicates all data from primary to 2 secondary postgres nodes. Managed by Patroni to ensure there is only one leader at a time, using etcd as distributed consensus primitive for election.

Automatically fails over to a secondary if primary is unavailable (while invalidating primary's lease on writes).

## Common Use Cases

- Database replication
- Failover in case primary goes down
- Avoiding split brain in HA systems

## Dependencies for Postgres HA Hosting

- Etcd cluster (3 nodes) for election
- PostgreSQL as database primitive
- Patroni as HA mechanism, managing leadership (write leases)
- HA Proxy to proxy connections to the leader

### Deployment Dependencies

- https://etcd.io/
- https://github.com/patroni/patroni
- https://www.haproxy.org/

## Why Deploy Postgres HA on Railway?

To ensure your database recovers quickly if the machine they run on goes down. Automatically replicating and failing over to a secondary if the primary goes down.

## Similar templates

- [Rocky Linux](https://railway.com/deploy/rocky-linux) — [Jul'26] Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀
- [Foundry Virtual Tabletop](https://railway.com/deploy/X5tR6G) — A Self-Hosted & Modern Roleplaying Platform
- [Letta Code Remote](https://railway.com/deploy/letta-code-remote) — Run a Letta Code agent 24/7. No inbound ports, just deploy.

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