Skip to content
AnswerWell geo Documentation

Research · 4 min read · Answerwell

Load Balancing Health Monitor expected_body Match and Response Limits

Why health monitors fail when expected_body is missing from the response, the 10 KB read limit, and how to fix body-match errors.

This page summarises Cloudflare documentation on load balancing and health check monitors that validate an expected_body string in the origin response. If a pool looks unhealthy but the endpoint works in a browser, the monitor may be reading only the first portion of the body or the match string may be placed too late in the payload.

Health monitor expected_body: what it checks

Section titled “Health monitor expected_body: what it checks”

A health monitor can require that the response body contain a configured substring. Cloudflare compares the monitor’s expected_body setting against what the origin returns. The match is case-insensitive: the body must include that value, but letter casing does not have to match exactly.

When the substring is absent from the portion of the body the monitor reads, the check fails even if your application is otherwise healthy.

Why the monitor fails when expected_body is not in the first 10 KB

Section titled “Why the monitor fails when expected_body is not in the first 10 KB”

The most common misconfiguration is assuming the monitor scans the entire response. Cloudflare only reads the first 10 KB of the response body when evaluating expected_body.

The response body returns from your endpoint and does not include the (case-insensitive) value of expected_body configured in your monitor.

Note that we only read the first 10 KB of the response. If you return a larger response, and the expected_body is not in the first 10 KB, the health monitor request will fail.

— Cloudflare, Common error codes

The same cause and fix appear in Health Checks analytics and Smart Shield health checks analytics, so behaviour is consistent whether you troubleshoot from load balancing error codes or health-check analytics views.

Typical situations that trigger this failure:

  • A large HTML or JSON payload where status text or a health token appears only after dashboards, stack traces, or verbose debug fields.
  • Compression or middleware that prepends boilerplate, pushing the real health marker beyond the 10 KB window.
  • An API that returns a long list first and puts "status":"ok" or similar near the end.

How to fix expected_body placement in the response

Section titled “How to fix expected_body placement in the response”

Cloudflare’s prescribed fix is direct:

Ensure the expected_body is in the first 10 KB of the response body.

— Cloudflare, Common error codes

Practical approaches:

  1. Add or narrow a lightweight health route whose body is only the match token (or a tiny JSON object that includes it at the top).
  2. Point the monitor at that route instead of a heavy homepage or report URL.
  3. Shorten responses used for monitoring: remove nonessential fields that appear before the match string.
  4. Re-read expected_body for typos; remember matching is case-insensitive but the substring must still appear verbatim aside from case.

Not every failure maps to a specific error bucket. When Cloudflare cannot classify a failure as another documented type, documentation describes it as a catch-all:

If the failure cannot be classified as any other type of failure mentioned above.

— Cloudflare, Common error codes

Use Health Checks analytics or Smart Shield health checks analytics to see whether failures correlate with body-match errors versus timeouts, HTTP status mismatches, or other monitor settings. Resolve known patterns (including the 10 KB expected_body rule) before assuming an unknown root cause.

Mistake Why it fails
Monitoring a page that streams a large JSON array before status fields Match string may sit after 10 KB of data
Reusing expected_body from a manual curl of a truncated response Your test client might not show that the live response exceeds 10 KB
Matching on HTML comments or metadata at the bottom of the document First 10 KB may be <head> and assets only
Omitting a dedicated health URL Production pages rarely keep critical tokens at the very start
  1. In the Cloudflare dashboard, open your load balancer or health check configuration and note the monitor URL and the exact expected_body value.
  2. From a shell, fetch the monitor URL and inspect size and content order—for example, confirm the match string appears within the first 10 KB (roughly 10,240 bytes) of the raw body.
  3. Review failure reasons in Health Checks analytics or Smart Shield health checks analytics and cross-check with Common error codes.
  4. After moving the match string or switching to a minimal health endpoint, wait for the monitor interval to pass and confirm the pool shows healthy.
  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact sentence you are asking about, and we will correct or clarify it.