HTTP 4xx and 5xx in Kubernetes — Which Hop Sent It and How to Fix It
How to tell which hop wrote a 4xx or 5xx (CDN, cloud load balancer, Ingress, mesh sidecar, app or API server) and how to fix 400, 401, 403, 405, 408, 499, 409, 410, 414, 431, 422, 426, 429 and 500.
Overview
A status code on its own tells you very little. Between a user and the orders pods in prod there can be a CDN or web application firewall (WAF), a cloud load balancer, an Ingress controller or Gateway, a service mesh sidecar and finally the application. Any of those hops can answer on its own, and each one uses the same numbers to mean slightly different things. Separately, kubectl, controllers and GitOps tools talk to the Kubernetes API server, which returns HTTP codes too, and there 409, 410 and 422 have precise meanings of their own.
So work outside-in and ask one question first: which hop wrote this response? The response headers, the shape of the body and the access log of each proxy answer that in a minute. Only then read the code. A 403 with an nginx HTML body and nothing in the app log is an allow-list; the same 403 as JSON from the app is a business rule; RBAC: access denied is the mesh.
The one idea to keep: find the hop, then the code, then the cause. Most wasted hours on 4xx and 5xx come from debugging the application for a response it never produced.
The examples use ingress-nginx because it is still everywhere, but the Kubernetes project retired it in March 2026: no more fixes or security patches. Gateway API is the successor, and many of its implementations are built on Envoy, so learn to read Envoy's responses and response flags as well as nginx's.
Which hop answered
Every hop leaves its own fingerprint in the response, and each keeps its own log. Read the fingerprint first, then go to that log.
- A CDN or WAF in front: server: cloudflare plus cf-ray, a via header naming CloudFront plus x-amz-cf-id, or x-azure-ref from Front Door. The evidence is in the CDN or WAF log, not the cluster.
- The cloud load balancer: server: awselb/2.0 on ALB-generated errors, Microsoft-Azure-Application-Gateway/v2, or via: 1.1 google on GKE. Look in the ALB access log (elb_status_code), the App Gateway access log, or the load balancer's statusDetails.
- ingress-nginx: server: nginx with no version and a small HTML page with nginx. In the controller access log, upstream_status is - when nginx answered itself.
- Envoy (Istio, Envoy Gateway): server: istio-envoy or envoy, plain-text bodies such as no healthy upstream, and x-envoy-upstream-service-time only when the upstream answered. Its access log carries %RESPONSE_CODE% and %RESPONSE_FLAGS%, short reason codes: UH (no healthy upstream), UF (upstream connection failure), UT (upstream timeout), NR (no route), DC (downstream disconnect) and RL (rate limited).
- Your application: its own JSON error body and headers. Find the app log line with the same X-Request-ID.
- The Kubernetes API server: a JSON Status object with reason and code, which kubectl prints as Error from server (Reason). It is recorded in the audit log, and a kubectl error without from server never left your machine.
Key concepts
- Hop attribution
- upstream_status
- Envoy response flags
- 499 and its equivalents
- resourceVersion
- Field manager
- Watch bookmark
- Strict field validation
- API Priority and Fairness
- large_client_header_buffers
Interview questions
- A user sends a screenshot showing only a status code. How do you work out which hop produced it?
- Office users get 403 on api.corp.com while everyone else works. The app logs nothing. The cluster runs ingress-nginx behind a cloud network load balancer. Walk me through it.
- Your CI pipeline started failing with an apply conflict on .spec.replicas right after the team added an HPA. What happened and what do you change?
- The ingress-nginx dashboard shows a jump in 499s but almost no 5xx. The product team says it is just mobile users on bad networks. Do you agree?
- After the identity team added group claims to tokens, some users on your AKS cluster get 400 Request Header Or Cookie Too Large, and a few get 431. Traffic goes Application Gateway, ingress-nginx, Istio sidecar. How do you fix it?
- Your operator's logs fill with "too old resource version" and it keeps crash-looping. How do you reason about it?
- Your team moved API rate limiting from ingress-nginx to AWS WAF in front of the ALB on EKS. Client SDKs that handled 429 now fail hard. Why, and how would this differ on GKE?
Sign up free to read the full topic
More DevOps topics
- HashiCorp Vault
- Helm 4 Migration
- Helm vs Kustomize
- HelmRelease and helm-controller
- High Availability System Design
- How User Requests Travel in Kubernetes
- IaC Governance
- IaC State Management
- Identity, Secrets and Config Errors — Workload Identity, Stale ConfigMaps and Secret Stores
- Image Update Automation
- Immutable Infrastructure
- Infrastructure as Code
Start free on Cariara · Coding problems · System design studio