Website returns 200 but shows error? How to catch soft errors

A status code only tells you the server answered. It does not tell you what the page says. Here is how to confirm a page is broken even though it returns 200, and how to alert on it.

Updated

Short answer

The server, a proxy or the framework is returning 200 with an error page in the body, so a status-code check passes. Fetch the page with curl -s and grep for the text you expect, then set up a keyword monitor that alerts when that text is missing or an error string appears.

Start keyword monitoring free

Why a 200 can still be a broken page

The status code is set by whatever answers the request, and that is not always the part that failed. A proxy, CDN or error handler can return its own page with a 200. Often the application catches an exception, renders an error template, and nobody changed the status. These are called soft errors, and a monitor that only checks the status code reports them as up.

What the visitor seesTypical causeWhy it returns 200
"Error establishing a database connection" or a stack traceDatabase down or out of connectionsThe app catches the error and renders a message without setting a 5xx status
Blank white pageFatal error with display turned off, or a crashed templateOutput is empty but the response was sent successfully
"Down for maintenance"Maintenance mode left on after a deployThe maintenance page is served with 200 instead of 503
Login or consent wall instead of the pageExpired session config, misrouted rule, bot protectionThe redirect or challenge page is itself a valid response
Host or CDN default page ("Welcome to nginx", "Domain parked")Wrong origin, deleted site, DNS pointing at the wrong serverThe default server answers normally

Check it with curl and grep

Fetch the body and search for a phrase that only appears on a healthy page, such as a heading or a product name. -s hides the progress bar, -i on grep ignores case, and -q makes grep print nothing and just set the exit code.

Is the expected text there?Shell
curl -s https://example.com/ | grep -qi "Welcome to Example" && echo OK || echo MISSING

Then search for text that should never be there:

Is an error string present?Shell
curl -s https://example.com/ | grep -iE "database error|fatal error|maintenance|stack trace"

To see the status and the timing in one line, ask curl to print them and discard the body:

Status code and total timeShell
curl -s -o /dev/null -w '%{http_code} %{time_total}s\n' https://example.com/

What to check for

Use both directions. Expected text catches a blank page, a parked domain and a login wall, because the real content is simply absent. Forbidden text catches a known error message even when the rest of the page still renders.

  • Expected: a heading, the site name in the footer, or a string in an API response such as "status":"ok".
  • Forbidden: the exact wording your stack uses for database errors, maintenance mode and fatal errors.
  • Be specific: Database connection timeout is safer than error, which can appear in a script or a nav label.

Add a response-time check as well. A page that technically loads but takes 20 seconds is often the first symptom of the same database problem.

Set it up in UptimeIO

  1. Create a monitor and choose the Keyword type.
  2. Enter the page URL, then the interval and timeout as for an HTTP monitor.
  3. In Keyword Configuration, add the expected text as Contains and error strings as Excludes.
  4. Turn on Slow Response Alert under SSL, domain & performance alerts and set a threshold.
  5. Choose where alerts go: email, Slack, Telegram, Pushover or a webhook.

How the matching behaves:

  • Contains / Excludes: Contains fails the check when the text is missing. Excludes fails it when the text is present.
  • Several keywords: up to 20, each up to 500 characters. Match all (default) or Match any applies to the Contains keywords. Any Excludes keyword that appears fails the check.
  • Case: off by default, so error also matches Error. Turn on Case sensitive to match exactly.
  • Plain text only: regular expressions are not supported, so add one keyword per phrase.
  • Body only: response headers are not searched, and HEAD requests cannot be used because they have no body.
  • Status code: checked first. Only 200 passes unless you change Expected Status.
  • Slow responses: the threshold is 100 to 30,000 ms. A slow response opens a separate incident, and the monitor can be up while it is open.

Test your keywords against the page source first, using the curl commands above. If the monitor reports a keyword missing that you can see in the browser, the text is probably added by JavaScript, or the server sends a different page depending on cookies or user agent.

Questions

Why does my website return 200 but show an error?
Because the thing that produced the error page did not change the status code. An application error handler, a maintenance plugin, a CDN or a default server page can all send a 200 with the wrong content.
Can uptime monitoring detect a blank page?
Only if it checks content. A keyword monitor with a Contains keyword for something on the real page fails when the body is empty or different.
Is keyword matching case sensitive?
Not by default in UptimeIO. `error` matches `Error` and `ERROR`. There is a Case sensitive switch that applies to all keywords on the monitor.
Can I use regular expressions?
No. Matching is plain text, so add a separate keyword for each phrase you want to look for.
Will it see content that JavaScript adds after the page loads?
No. The monitor searches the response body the server returns. Pick text that is in the initial HTML, or monitor an API endpoint the page depends on.

Related

Start monitoring in a few minutes

Start monitoring free

Free plan · 50 monitors · No credit card required