Troubleshooting · Networking, TLS & health checks
Health check green but requests fail? 7 causes, ranked
7 causes, most common first · last reviewed
TL;DR
A health check only proves what it tests. Most often it returns 200 from memory while the thing real requests need, a database connection, a thread or a downstream service, is exhausted or down. Send the same request a user sends to one instance directly, and compare it with the health endpoint.
On this page
Quick triage: the first five minutes
Hit the health endpoint and a real endpoint on the same instance, side by side, with timings.
Shellfor p in /actuator/health/readiness /api/orders/123; do curl -sS -o /dev/null -w "$p %{http_code} %{time_total}s\n" http://10.0.4.17:8080$p doneHealth 200 in milliseconds, real request 5xx or slow: the check does not cover what is failing. Find where the errors are produced: the load balancer, the proxy or the application. The status code and the response body usually say which.
Shellcurl -sv https://api.example.com/api/orders/123 2>&1 | grep -E '^< (HTTP|server|via)'A 502 or 504 with the load balancer's server header was produced in front of the app. Check the app's own resources: database pool, thread pool, open connections.
Shellcurl -s localhost:8080/actuator/metrics/hikaricp.connections.pending curl -s localhost:8080/actuator/metrics/tomcat.threads.busy
The causes, ranked
Most common first. The ranking is a judgement from how these failures usually turn out, not a measured statistic.
1. The check does not touch what requests need
What it looks like
- The health endpoint returns 200 instantly while most real requests fail or time out.
- Errors in the logs are about a dependency: connection timeouts, refused connections, pool timeouts.
- Every instance is failing at once, yet none has been taken out of rotation.
How to confirm it
Read what the health endpoint actually checks. A handler that returns a constant, or a liveness endpoint used for routing, proves only that the process is up. Compare its result with a request that uses the database.
Fix it now
Route traffic on a readiness check that includes the critical dependencies, and keep liveness shallow. In Spring Boot, readiness and liveness are separate health groups you can compose.
management.endpoint.health.probes.enabled=true
management.endpoint.health.group.readiness.include=readinessState,db
management.endpoint.health.group.liveness.include=livenessStatePrevent it
Do not put dependencies in liveness: if the database goes down, a deep liveness check restarts every pod at once, which turns an outage into a restart storm. Readiness removes pods from traffic; liveness kills them.
2. Connections or threads are exhausted
What it looks like
- Requests wait and then fail with pool timeouts, while database CPU is low.
- Instances that already hold a connection keep passing checks; anything needing a new one fails.
- hikaricp.connections.pending above zero, or busy threads at the maximum.
How to confirm it
Look at pool metrics and the database's connection count. If the database is at max_connections, even you may be locked out of a console unless a slot is reserved for administrators.
SELECT count(*) AS used, current_setting('max_connections') AS max
FROM pg_stat_activity;Fix it now
Free connections first: find long transactions and leaks, then size the pools across all instances to fit the database. The connection pool guide below covers it step by step.
Prevent it
Alert on pool wait time and on database connections as a share of max_connections, well before 100%.
3. The check and the traffic take different paths
What it looks like
- The check calls the pod or instance directly, while users come through an ingress, a gateway or TLS termination that is failing.
- Health is green on the load balancer, but the error comes from a hop in front of or behind it.
- The check uses a different port, host name or protocol from real traffic.
How to confirm it
Trace one real request hop by hop: DNS, load balancer, ingress, service, pod. Check that the service actually has ready endpoints and that the ingress routes to the port the app serves.
kubectl get endpointslices -n shop -l kubernetes.io/service-name=checkout
kubectl describe ingress checkout -n shopFix it now
Point the check at the same listener, port and host that users hit, or add an end-to-end synthetic check that goes through the public path.
Prevent it
Keep at least one external synthetic check that follows exactly the path a customer's request takes.
4. Bad instances stay in rotation
What it looks like
- A fraction of requests fail, roughly one in N, matching one bad instance out of N.
- Errors come and go as the check flaps between passing and failing.
- The check interval and failure threshold add up to minutes before removal.
How to confirm it
Break errors down by instance or pod. If one instance produces most of them, the check is either too lenient or too slow to notice. On AWS, describe-target-health shows each target's state and reason.
aws elbv2 describe-target-health --target-group-arn "$TG_ARN" \
--query 'TargetHealthDescriptions[].[Target.Id,TargetHealth.State,TargetHealth.Reason]' --output tableFix it now
Take the bad instance out by hand, then tighten the interval and unhealthy threshold. Consider outlier detection on error rate, which reacts to real traffic rather than to a probe.
Prevent it
Graph errors per instance; an average across the fleet hides one broken member.
5. The app is slow, not down
What it looks like
- Real requests time out at the load balancer or client, often as 504, while the cheap health endpoint answers in time.
- Latency rises with load; the health endpoint's latency does not.
- Thread dumps show requests waiting on locks or downstream calls.
How to confirm it
Compare the request timeout chain: client, load balancer idle timeout, proxy, app. A request that takes longer than any hop's timeout fails there, whatever the health check says.
jcmd <pid> Thread.print > threads.txt
grep -c 'java.lang.Thread.State: BLOCKED' threads.txtFix it now
Find the slow dependency or lock and cut it off with a timeout shorter than the caller's. Shed load if the app is simply over capacity.
Prevent it
Set timeouts so each hop gives up before the hop in front of it; include a latency threshold in readiness if slowness should remove an instance.
6. A dependency outside the check is down
What it looks like
- Only some endpoints fail: the ones that call a particular third-party API, cache or internal service.
- Errors mention DNS resolution, TLS handshakes or connection refusals to one host.
- Health stays green because that dependency is deliberately not part of it.
How to confirm it
Group failing requests by endpoint and by the dependency they call. Test the dependency from inside the instance, not from your laptop.
kubectl exec -n shop deploy/checkout -- sh -c 'getent hosts payments.internal && curl -sS -m 3 -o /dev/null -w "%{http_code}\n" https://payments.internal/health'Fix it now
Degrade the affected feature, with a fallback or a circuit breaker, instead of failing whole pages. Decide explicitly whether this dependency should affect readiness.
Prevent it
List each dependency with what should happen when it is down, and test that behaviour.
7. Healthy servers, but traffic never reaches them
What it looks like
- Servers are up and checks pass, yet request volume at the servers drops towards zero.
- Users see DNS failures or connection timeouts, not application errors.
- A change was made to DNS, routes or the edge shortly before.
How to confirm it
Check from outside your network: resolve the name through public resolvers and test reachability from more than one location. A health check run from inside your network cannot see a routing or DNS failure on the way in.
dig +short api.example.com @8.8.8.8
dig +trace api.example.com | tail -5
curl -sS -o /dev/null -w '%{http_code} %{remote_ip}\n' https://api.example.com/healthzFix it now
Roll back the DNS or routing change, or move traffic to a path you have confirmed from outside.
Prevent it
Probe from outside your own network, and make any check that gates a cutover verify the real thing, for example that routes are actually advertised, not that a process is running.
See it happen in a real outage
90-second puzzles built from public postmortems. Diagnose it first; the company is revealed after you answer.
- Outage puzzleHealthy, but can't connectWorkers pass every health check while the app fails, and the on-call engineer cannot even open a database console.Diagnose it
- Outage puzzleThe check said it was announcingNew servers pass their health check, the old ones are switched off, and traffic to a whole city disappears.Diagnose it
Related concepts
FAQ
Why is my health check passing but the app is returning 502 or 503?
The check tests something narrower than real requests, or takes a different path. A 502 or 503 is often produced by the load balancer or proxy in front of a healthy process, for example when no backend is ready, or when the app's own connections to a dependency are exhausted.
Should a health check include the database?
Include it in readiness, which controls whether an instance receives traffic. Keep it out of liveness, which restarts the process: a database outage would otherwise restart every instance at once.
What is the difference between liveness and readiness probes?
Liveness answers whether the process should be restarted. Readiness answers whether it should receive traffic right now. A pod can be alive but not ready, for example while warming up or while a dependency is down.
Related troubleshooting guides
- DatabasesDatabase connection pool exhausted? 7 causes, ranked
- KubernetesKubernetes HPA not scaling down? 6 causes, ranked
Reference documentation: Kubernetes documentation: configure liveness, readiness and startup probes ↗ · Spring Boot reference: Actuator endpoints and Kubernetes probes ↗ · AWS documentation: describe-target-health ↗ · Report a problem
Commands and settings are checked against the documentation linked above. Defaults change between versions; check the documentation for the version you run.