Next Practical Step
Inspect the response body of failed 5xx samples in View Results Tree and check server-side APM/Kubernetes restart logs.
Troubleshoot JMeter HTTP 500, 502 Bad Gateway, 503 Service Unavailable, and 504 Gateway Timeout errors during load testing with root causes and fixes.
During load testing, JMeter samples turn red in View Results Tree, the HTML dashboard reports elevated error rates, and samplers return HTTP 5xx status codes:
Response code: 500 (Internal Server Error)Response code: 502 (Bad Gateway)Response code: 503 (Service Unavailable)Response code: 504 (Gateway Timeout)Unlike Non HTTP response code errors (which indicate client or TCP failures), HTTP 5xx codes are valid HTTP responses returned by the backend application, reverse proxy, or API gateway.
| Status Code | Layer | Root Cause |
|---|---|---|
| 500 Internal Server Error | Application / DB | Code exceptions, database connection deadlocks, unhandled edge-case payload |
| 502 Bad Gateway | Ingress / Proxy / Envoy | Upstream app crashed (OOM), closed socket prematurely, or pod restarted during test |
| 503 Service Unavailable | Gateway / Rate Limiter | Server overload, connection pool backlog saturated, circuit breaker open |
| 504 Gateway Timeout | Reverse Proxy / Load Balancer | Application took longer than proxy timeout (e.g. Nginx proxy_read_timeout 60s) |
HTTP 5xx responses usually contain informative JSON or HTML error payloads explaining the failure. In JMeter GUI (during single-thread validation):
# Add to user.properties for debugging runsjmeter.save.saveservice.response_data.on_error=trueIf seeing bursts of 502 errors at high concurrency:
# Kubernetes pod statuskubectl get pods -n production -w# Look for OOMKilled or Restarts > 0connect() failed (111: Connection refused) while connecting to upstreamHTTP 502: TargetConnectionErrorWhen 503 errors occur:
maxThreads, Node.js cluster, Puma/Unicorn workers).maximumPoolSize). If the pool is exhausted, requests queue up until timeout.If 504 errors spike:
# Nginx proxy timeout tuningproxy_connect_timeout 120s;proxy_send_timeout 120s;proxy_read_timeout 120s;Do not assume HTTP 200 is always a success; some flawed APIs return HTTP 200 with an embedded {"error": "Internal database error"} payload. Add Response Assertions checking for expected JSON fields or status strings (API guide).
| Resource | Use when |
|---|---|
| SocketTimeoutException | Client-side timeout before receiving any bytes |
| Throughput stuck | Requests queuing and throughput collapsing under load |
| Coordinated Omission | Measuring true user impact when servers stall |
| Generating Dashboard | Viewing Top 5 Errors table in HTML report |
No. An HTTP 500 is generated strictly by the server application. However, JMeter may trigger it if your test sends invalid JSON data, missing headers, or unexpected concurrency that exposes race conditions in the server code.
Add a Response Assertion under the sampler, check Ignore Status, and add 500 to the patterns to test.