---
title: "Deploy Patroni"
description: "Patroni is a template for high availability (HA) PostgreSQL."
category: "Storage"
url: https://railway.com/deploy/patroni
---

# Deploy Patroni

Patroni is a template for high availability (HA) PostgreSQL.

**[Deploy Patroni on Railway](https://railway.com/template/patroni)**

- **Creator:** Noah templates
- **Category:** Storage
- **Total deploys:** 3

## Template content

### Patroni Worker 1 https://avatars.githubusercontent.com/u/141222901?v=4

- **Source:** patroni/patroni
- **Start command:** `/bin/sh -c 'chown -R 999:999 /data && apt update && apt install gosu && export DOCKER_IP=$(hostname -I | tr " " "\n" | grep -E "^fd12:" | head -1) && export PATRONI_NAME=$(hostname) PATRONI_RESTAPI_CONNECT_ADDRESS=$DOCKER_IP:8008 PATRONI_POSTGRESQL_CONNECT_ADDRESS=$DOCKER_IP:5432 && exec gosu postgres dumb-init python3 /patroni.py postgres0.yml'`

### ETCD Worker 3 https://www.svgrepo.com/show/353714/etcd.svg

- **Source:** patroni/patroni
- **Start command:** `etcd --name etcd3`

### Patroni Worker 3 https://avatars.githubusercontent.com/u/141222901?v=4

- **Source:** patroni/patroni
- **Start command:** `/bin/sh -c 'chown -R 999:999 /data && apt update && apt install gosu && export DOCKER_IP=$(hostname -I | tr " " "\n" | grep -E "^fd12:" | head -1) && export PATRONI_NAME=$(hostname) PATRONI_RESTAPI_CONNECT_ADDRESS=$DOCKER_IP:8008 PATRONI_POSTGRESQL_CONNECT_ADDRESS=$DOCKER_IP:5432 && exec gosu postgres dumb-init python3 /patroni.py postgres0.yml'`

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

- **Source:** thesamgordon/patroni-haproxy
- **Public domain:** Yes

### ETCD Worker 2 https://www.svgrepo.com/show/353714/etcd.svg

- **Source:** patroni/patroni
- **Start command:** `etcd --name etcd2`

### Patroni Worker 2 https://avatars.githubusercontent.com/u/141222901?v=4

- **Source:** patroni/patroni
- **Start command:** `/bin/sh -c 'chown -R 999:999 /data && apt update && apt install gosu && export DOCKER_IP=$(hostname -I | tr " " "\n" | grep -E "^fd12:" | head -1) && export PATRONI_NAME=$(hostname) PATRONI_RESTAPI_CONNECT_ADDRESS=$DOCKER_IP:8008 PATRONI_POSTGRESQL_CONNECT_ADDRESS=$DOCKER_IP:5432 && exec gosu postgres dumb-init python3 /patroni.py postgres0.yml'`

### ETCD Worker 1 https://www.svgrepo.com/show/353714/etcd.svg

- **Source:** patroni/patroni
- **Start command:** `etcd --name etcd1`

## Documentation

# Deploy and Host Patroni on Railway

Patroni is a template for high availability (HA) PostgreSQL solutions using Python. Database engineers, DBAs, DevOps engineers, and SREs who are looking to quickly deploy HA PostgreSQL in datacenters - or anywhere else - will hopefully find it useful.

## Common Use Cases

- Extremely high availability hosted Postgres.
- Postgres that never, ever goes down.

## HAProxy Configuration
When you deploy HAProxy, a password will be generated under the variable `STATS_PASSWORD`. You can use this with the username `admin` to log into the statistics page at the service's public domain.

HAProxy template configuration: https://github.com/thesamgordon/patroni-haproxy/blob/main/haproxy.template.cfg



## Similar templates

- [Garage S3 Storage](https://railway.com/deploy/garage-s3-storage) — Ultra-light S3 server: fast, open-source, plug-and-play.
- [Redis](https://railway.com/deploy/redis-1) — Self Host Latest Redis with Railway
- [EasyImg](https://railway.com/deploy/easyimg) — Simple self-hostable Nuxt.js personal image hosting system.

Open this page in a browser: https://railway.com/deploy/patroni
