Why a 200 OK doesn't mean your site works (and what to check instead)

Servers can return 200 with an error page, an empty shell or stale content. How these failures happen and how keyword and JSON checks catch what status codes miss.

· 6 min read · By the Spot Downtime team

Most uptime checks ask one question: did the server answer with a good status code? A 200 OK passes, a 500 fails. That catches a lot, but not everything. A page can return 200 and still show an error message, an empty product list or a blank screen. To the monitor it is up. To the customer it is broken.

This post covers how those failures happen, why they are so common, and how to check for the content that proves a page really works.

How a 200 hides a failure

Error pages sent with the wrong status

Some applications catch an exception and render a friendly error page, but forget to set the status code. The framework default is 200, so a database failure arrives as "Something went wrong" with a success status. The same happens with custom 404 pages, which is the "soft 404" problem described in the 404 guide.

A cache or CDN serving a stale or empty page

A CDN can cache a bad response and keep serving it with 200. A cached page from before a deploy can reference scripts that no longer exist. The edge is healthy, the origin may be broken, and the status code tells you nothing about either.

A JavaScript shell that fails to load data

Single-page apps return the same small HTML file for every route. That file is a 200 even when the API behind it is down, and the visitor sees a spinner forever or an empty page. The HTML check passes while the real work fails.

An API that returns 200 with an error body

Some APIs answer every request with 200 and put the real result in the body, such as {"ok": false, "error": "db timeout"}. A GraphQL endpoint often does this: errors travel in the response body and the HTTP status stays 200.

A maintenance or parking page

A reverse proxy, a hosting provider or an expired domain can serve a placeholder page with 200. The domain answers, so a basic check passes, but your site is not there. If you plan maintenance, use a 503 with Retry-After so tools know it is deliberate.

Partial failure of a dependency

The page loads, but the checkout button, search results or price list is missing because one backend call failed and the template skipped that block silently.

Check for content, not just status

The fix is to make the monitor assert something only a working page would contain. For a website this is a keyword: a phrase that is present when the page works and missing when it does not.

  • Pick text from the part that breaks. For a shop, a button label such as "Add to cart" on a product page. For a dashboard login page, the name of the form field.
  • Prefer text from server-rendered HTML. A keyword check reads the response body, so text added later by JavaScript will not be there. Choose something present in the initial HTML.
  • Avoid text that also appears in the error page. If the error page repeats your site name or navigation, a keyword from the header would still match. Use text unique to the content area.
  • Keep it stable. A phrase from marketing copy changes with every redesign and will cause false alerts. A label or a structural string changes rarely.

You can test a candidate keyword by hand before adding it:

bash
# Does the working page contain the phrase?
curl -s https://shop.example.com/products/widget | grep -ci "add to cart"

# What does a broken response look like? Compare status and size
curl -s -o /dev/null -w "%{http_code} %{size_download}\n" https://shop.example.com/products/widget

A very small response size on a page that is normally large is a useful hint on its own, even when the status looks fine.

Check the body of API responses

For JSON APIs, assert on fields rather than words. Check that status equals ok, that a list is not empty, or that a queue depth is under a limit. A health endpoint that reports its dependencies is the cleanest option, as described in the API monitoring guide. Return a non-200 status from the health endpoint when a critical dependency is down, so even simple checks fail correctly.

Fix the cause too

Monitoring around a wrong status code is a patch. If your app returns 200 for errors, change it to return a 5xx for server failures and 404 for missing pages. Search engines and load balancers also rely on those codes, so the fix helps more than the monitor.

What Spot Downtime offers for this

A website monitor can require text on the page. If the text is missing, the monitor counts as down even when the server says 200. Keyword matching is case-insensitive and looks at the first 1 MB of the response. For APIs, API monitors support assertions on JSON fields, such as equals, contains, exists and greater or less than, up to 20 per monitor. Failures are confirmed from several regions before alerting, so a single odd response does not page you.

For flows that depend on JavaScript, such as a login followed by a dashboard, a status code and a keyword cannot see far enough. Browser monitoring runs a real browser through the steps instead.

A short checklist

  • List your five most important pages or endpoints and what proves each one works.
  • Add one keyword or JSON assertion per monitor, taken from content that only appears when things are healthy.
  • Make your app return real error statuses for real errors.
  • Review the keywords after redesigns, which are the usual source of false alerts. See reducing false uptime alerts.

Get new guides by email

Practical posts on monitoring, outages, error fixes and on-call, when they're published. No spam.

Unsubscribe from any email with one click. See our privacy policy.

Keep reading