Your failover record just moved traffic to the secondary site, or the health check alarm is red, but curl from your laptop returns 200. Route 53 health checkers do not see what you see: they connect from public AWS IP ranges in several Regions, with their own timeouts and request format. This post works out what they are seeing and fixes it.
Symptoms
- Health check status is Unhealthy in the console while the site works from your network.
- The status flaps between Healthy and Unhealthy every few minutes.
HealthCheckPercentageHealthysits somewhere between 0 and 100 instead of at 100.- Failover or weighted records route away from a primary that is serving traffic.
1. Read what the checkers saw
Each checker Region reports its own last result. Start here, not with the endpoint.
HC=abcd1234-5678-90ab-cdef-111122223333
# Configuration: type, IP/FQDN, port, path, SNI, search string, regions
aws route53 get-health-check --health-check-id "$HC" \
--query 'HealthCheck.HealthCheckConfig'
# Latest observation from every checker
aws route53 get-health-check-status --health-check-id "$HC" \
--query 'HealthCheckObservations[].[Region,IPAddress,StatusReport.Status]' \
--output table
# Last failure per checker, with the reason text
aws route53 get-health-check-last-failure-reason --health-check-id "$HC" \
--query 'HealthCheckObservations[].[Region,StatusReport.CheckedTime,StatusReport.Status]' \
--output table
The Status text is the most useful clue you will get. Typical values look like Failure: Connection timed out, Failure: HTTP Status Code 403, Failure: Resolved IP address ... is not public or Failure: The search string was not found. The wording varies, so match on the key phrase.
Tip
If only one or two Regions fail, the problem is usually network path or a geo/IP filter in front of the endpoint. If every Region fails with the same message, it is configuration: path, port, status code or search string.
2. Map the failure reason to a fix
| Reason (key phrase) | Likely cause | Fix |
|---|---|---|
| Connection timed out | Security group, NACL, WAF or on-premises firewall blocks the checker IPs | Allow the ROUTE53_HEALTHCHECKS ranges on the health check port |
| Connection refused | Wrong port, or the listener only binds to a private interface | Correct Port; check the listener |
| HTTP status code 301/302 then fail, or 4xx | Path redirects to login, or the app rejects the Host header | Point ResourcePath at a dedicated unauthenticated health URL |
| HTTP status code 403 | WAF or IP allow list blocks the checkers | Exception for checker ranges or a health-only path |
| Search string not found | String is not in the first 5,120 bytes of the body, or case differs | Move the string near the top or shorten it |
| TLS / SSL handshake failed | Server needs SNI and EnableSNI is false | Turn on SNI and set FullyQualifiedDomainName |
| Resolved IP is not public | FQDN resolves to a private address | Use a CloudWatch alarm-based health check instead |
| Timeouts on slow pages | Response took longer than the checker allows | Make the health endpoint cheap and fast |
3. Fix the usual causes
Checkers blocked by firewalls
Health checkers come from published AWS ranges. Pull them from ip-ranges.json:
curl -s https://ip-ranges.amazonaws.com/ip-ranges.json \
| jq -r '.prefixes[] | select(.service=="ROUTE53_HEALTHCHECKS") | .ip_prefix' | sort -u
Add those ranges to the security group, NACL or perimeter firewall for the health check port only. The list changes, so automate the update (for example, a Lambda function subscribed to the AmazonIpSpaceChanged SNS topic) rather than pasting it once.
Warning
Do not open the port to
0.0.0.0/0to make the health check go green. Allow only the checker ranges, and only on the port the check uses.
You can also reduce how many Regions probe the endpoint (minimum three) if your firewall team needs a smaller list:
aws route53 update-health-check --health-check-id "$HC" \
--regions us-east-1 us-west-2 eu-west-1
Response too slow
For HTTP and HTTPS checks the checker must open the TCP connection within four seconds, and the endpoint must return a 2xx or 3xx status within two seconds after connecting. A health URL that queries the database, warms a cache or renders a full page will fail under load. Serve a static or near-static response from the health path and check dependencies asynchronously.
# Time it the way a checker does: connect + first byte
curl -o /dev/null -s -w 'connect=%{time_connect} ttfb=%{time_starttransfer} code=%{http_code}\n' \
https://app.example.com/healthz
Run that from a host outside your corporate network, not from inside the VPC.
HTTPS, SNI and the Host header
Route 53 HTTPS checks do not validate the certificate, but many servers (CloudFront, shared ALB listeners, nginx with several server blocks) refuse the handshake without SNI. When you set FullyQualifiedDomainName, the checker also sends it as the Host header.
aws route53 update-health-check --health-check-id "$HC" \
--fully-qualified-domain-name app.example.com \
--enable-sni \
--resource-path /healthz
If you check by IPAddress with no FQDN, the Host header is the IP address, which virtual-hosted apps often reject with 400 or 404.
Search strings
HTTP_STR_MATCH and HTTPS_STR_MATCH only look in the first 5,120 bytes of the response body, and the match is case-sensitive. Return a small body such as {"status":"ok"} and search for "ok".
aws route53 update-health-check --health-check-id "$HC" --search-string '"status":"ok"'
4. Private endpoints and composite health
Checkers cannot reach private IPs. For an internal ALB or a database, use a CloudWatch alarm-based health check. The alarm must exist in the Region you reference:
aws route53 create-health-check --caller-reference "int-alb-$(date +%s)" \
--health-check-config '{
"Type": "CLOUDWATCH_METRIC",
"AlarmIdentifier": {"Region": "eu-west-1", "Name": "internal-alb-unhealthy-hosts"},
"InsufficientDataHealthStatus": "LastKnownStatus"
}'
For a service with several endpoints, a CALCULATED check combines child checks with HealthThreshold so one bad node does not fail the whole site:
aws route53 create-health-check --caller-reference "site-$(date +%s)" \
--health-check-config '{
"Type": "CALCULATED",
"ChildHealthChecks": ["'"$HC_A"'", "'"$HC_B"'", "'"$HC_C"'"],
"HealthThreshold": 2
}'
5. Flapping
Route 53 treats an endpoint as healthy when more than 18% of checkers report it healthy, and each checker needs FailureThreshold consecutive results before it changes its own view. Flapping usually means one or two Regions are intermittently blocked or slow. Fix the network cause first. Then, if the endpoint is merely slow to recover after deploys, raise the threshold:
aws route53 update-health-check --health-check-id "$HC" --failure-threshold 5
Caution
Raising
FailureThresholdor using a 30-second interval also delays real failover. Agree the detection time with whoever owns the RTO before you change it.
Prevent it next time
- Give every service a dedicated
/healthzpath: unauthenticated, not cached, under 1 KB, and fast. - Manage checker IP allow lists from
ip-ranges.jsonautomatically. - Alarm on
HealthCheckPercentageHealthyas well asHealthCheckStatus. Health check metrics are published in us-east-1, so create the alarms there:
aws cloudwatch put-metric-alarm --region us-east-1 \
--alarm-name r53-app-partial-unhealthy \
--namespace AWS/Route53 --metric-name HealthCheckPercentageHealthy \
--dimensions Name=HealthCheckId,Value="$HC" \
--statistic Average --period 60 --evaluation-periods 5 \
--threshold 90 --comparison-operator LessThanThreshold \
--alarm-actions arn:aws:sns:us-east-1:111122223333:ops-alerts
- Include the health check in deployment tests: when a release changes the health path or the WAF rules, test it from outside before cut-over.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get