Skip to content
Sign in to Bench
All writing

Essay

What a green health check does not tell you

Why the status code answers first and the body answers second, and how a check that reads only the status code calls a broken service healthy.

A watch shop does not lose its job history to a memory lapse as often as it loses it to a bad system. The register is honest. If the page is blank, the page is blank. Software is different, because software can answer that everything is fine while something behind it is not.

That gap is where a lot of production debugging lives, and we’ve spent more time in it than we expected to. Here is what we settled on, and why it is worth asking a vendor about.

The status code is the first answer

Every service you run has an address that answers when you hit it. For a health endpoint, that answer is the point of the endpoint: it says whether the service can do its job right now.

The rule we hold ourselves to is simple. If the service cannot reach the database it needs, the health endpoint answers 503, not 200. Not a 200 with a sad body attached. The status code is the first answer, and it should be the one that is true.

We got this wrong. For a while our own health endpoint answered 200 on a failed database check. The route kept reporting success, so anything reading only the status code would have called it healthy. We changed the route to answer 503 and deployed it on 10 November 2026. That is the version running now.

The body is the second answer

A status code is for machines. A human reading the endpoint wants to know what failed and how badly, so the body carries it.

Here is the shape of what our health route returns now:

dbState, dbError, dbErrorClass, dbErrorCode, dbAttempts, dbRetried

dbState is the answer in one word. dbError, dbErrorClass and dbErrorCode say what went wrong when it went wrong. dbAttempts counts the connection attempts, and dbRetried says whether a retry was needed. A monitor can assert on dbState, and a person can read the rest.

A monitoring check that reads only the status code

The obvious way to monitor a service is to look at the status code. Keep it simple, assert on 200, raise an alert when it is not 200. This works right up until the moment the service answers 200 with an error page inside it.

There are two ways that happens. The first is the one we hit: the route returns 200 and puts the failure in the body, so a probe that only checks the number never sees it. The second is a page that answers 200 with a styled not found on it, which is a real pattern for anything serving HTML from a catch-all route. Both look identical to a check that only looks at the status code.

Our own monitor was on the right side of this. It expected db=ok in the body, so when the database check failed it went red and said which check had failed, even though the status line still said healthy. That is the whole reason we caught the bad route at all.

So the checks worth writing assert on something in the body. Assert on dbState. Assert that the response contains the marker you expect from the page you meant to fetch. Assert that a public certificate page returns a certificate or a deliberate not found, and never a styled error page that still answers 200.

A failed connection is not a failed service

One more thing a health check has to get right, and it is easy to get wrong in the other direction. A connection can fail for reasons that have nothing to do with the service being down. The database may have been idle and slow to wake. Or the pooled connection in front of it may have gone bad, and the very next connection works fine.

We have seen the second one. Our health endpoint had two failed database checks in one morning, both of them inside steady traffic, so neither was a database waking up from idle. Both times the next attempt succeeded.

So the first database connection retries once before the route reports a failure. The body tells you it happened: dbAttempts goes to 2 and dbRetried goes to true. One retry, not an infinite loop, because a database that is genuinely down should stay down and stay loud. And a retry is a mask, not a cure. It keeps the monitor quiet while a stale connection problem is still there. If you are the one reading the body, dbRetried is the field that tells you the retry was load-bearing.

What to ask a vendor

None of this is exotic, and you do not need to be able to read a dashboard to use it. If a shop is about to run its job history, invoices and certificates on somebody else’s system, these four questions tell you most of what you need to know.

  1. What does your health endpoint return when the database is unreachable? A 200 with a body that says error is a valid answer, but you want to know which one it is.
  2. Does the body say what failed, or only that something did? A single status flag is fine for a probe, but it will not help you at 11pm.
  3. Does a failed connection produce a retry, and does the response tell you a retry happened? Otherwise the first alert of the morning will be a false one.
  4. Does your own monitoring assert on the body, or only on the status code? If the answer is only the status code, then their green light and your green light are worth the same as each other.

Our answers to those are the route above and the retry above. If you want to see what the rest of this looks like, the product is at /bench and the explanation of how the parts fit together is at /docs.