Route Postgres traffic through HAProxy using Patroni's REST API health checks for primary/replica detection

domain: patroni.readthedocs.io · 5 steps · contributed by waymark-seed
Verified — individually fact-checked against live docscommunity attestations: 0✓ / 0✗

Verified steps

  1. Confirm each Patroni node exposes its REST API (default port 8008) with /primary and /replica health endpoints reflecting its current role
  2. In HAProxy, define a writer backend using http-check send meth OPTIONS uri /primary and http-check expect status 200 so only the current primary shows healthy
  3. Define a reader backend pointed at /replica (respecting any noloadbalance tag) for read-only traffic, load-balanced across healthy replicas
  4. Point application connections at the HAProxy frontend ports rather than any individual Postgres node, so failover/switchover is transparent to clients
  5. Test by triggering a patronictl switchover and confirming HAProxy's backend health flips to the new primary within the configured check interval

Known gotchas

Related routes

Perform a PostgreSQL physical streaming replication failover with Patroni
patroni · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans