nginx access logs suddenly show a spike of `499` status codes.
IntermediateTroubleshootingLoad balancers and reverse proxies
Answer
Likely causes → 499 is nginx-specific: the client closed the connection before nginx sent a response. Either the upstream got slow and clients (or an LB in front) gave up, or a client/load generator uses aggressive timeouts.
Diagnose →
awk '$9 == 499 {print $7}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head
# with $request_time in log_format, check how long the 499 requests waited
If the 499s all cluster at e.g. exactly 60 s, an LB in front has a 60 s timeout.
Fix → Fix upstream latency, or align timeouts so nginx and the app time out before the outer layer does. If you need the upstream to finish work anyway, proxy_ignore_client_abort on; (use carefully).
Prevent → Alert on 499 rate together with upstream response time; they move together.
More on Load balancers and reverse proxies
nginx returns `502 Bad Gateway` and the error log says `connect() failed (111: Connection refused) while connecting to upstream`.Beginnernginx returns `504 Gateway Time-out` with `upstream timed out (110: Connection timed out) while reading response header from upstream`.BeginnerAn ALB target group shows all targets `unhealthy` with `Health checks failed with these codes: [404]`.BeginnerAn ALB returns sporadic `502`s, and access logs show `elb_status_code=502` with `target_status_code=-`. Load is low.Intermediatenginx logs `upstream prematurely closed connection while reading response header from upstream`.Intermediatenginx error log shows `no live upstreams while connecting to upstream` and every request gets 502.Intermediate