---
title: "Discussion on \"Patroni and HAProxy: which health check to use (/primary, /replica, /leader and the rest)\" | Hashnode"
description: "Discussion on \"Patroni and HAProxy: which health check to use (/primary, /replica, /leader and the rest)\". Originally published at https://twinhullhq.com/articles/patroni-haproxy-health-check-endpoints.html\nHAProxy cannot see which PostgreSQL node is the primary. It asks Patroni, over HTTP, and Patroni ans"
url: "https://hashnode.com/posts/patroni-and-haproxy-which-health-check-to-use-primary-replica-leader-and-the-rest/6ac5345329e5e72eb451d7b7"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Patroni and HAProxy: which health check to use (/primary, /replica, /leader and the rest)](https://twinhull.hashnode.dev/patroni-and-haproxy-which-health-check-to-use-primary-replica-leader-and-the-rest?utm_source=hashnode&utm_medium=feed)

Originally published at https://twinhullhq.com/articles/patroni-haproxy-health-check-endpoints.html HAProxy cannot see which PostgreSQL node is the primary. It asks Patroni, over HTTP, and Patroni ans

Oct 6 · 5 min read · twinhull.hashnode.dev  
Read the article

-   [#postgresql](https://hashnode.com/tag/postgresql)
-   [#devops](https://hashnode.com/tag/devops)
-   [#database](https://hashnode.com/tag/database)
-   [#databases](https://hashnode.com/tag/databases)
-   [#sre](https://hashnode.com/tag/sre)

## Written by

[Twinhull](https://hashnode.com/@twinhull)

@twinhull

  
[View profile](https://hashnode.com/@twinhull)

Twinhull publishes tested guides and free tools for running PostgreSQL high availability with Patroni, etcd, HAProxy and pgBackRest. Measured in a lab, not guessed.

## Responses 1

Markdown supported · ⌘↵ to post

[xin tian](https://hashnode.com/@pageflip)

[Oct 7](https://hashnode.com/posts/patroni-and-haproxy-which-health-check-to-use-primary-replica-leader-and-the-rest/6ac5345329e5e72eb451d7b7/comment/6ac606c07ff7616e50006b11)

This is a really useful distinction between checking whether PostgreSQL is alive and checking whether a node is actually suitable for a specific kind of traffic.

The point about `/health` being a poor choice for write routing stood out to me. A node can be perfectly healthy from PostgreSQL's perspective while still being the wrong target for writes. I also like the idea of testing the whole path through HAProxy rather than trusting the Patroni endpoint alone.

The `pg_is_in_recovery()` check is a nice final verification because it tests what the application actually reaches, not just what the health check reports. That kind of end-to-end validation seems especially valuable during failover.
