ingress-nginx returns 502 or 503 intermittently. What are the likely reasons?
IntermediateScenarioServices, Ingress and DNS
Answer
Situation read → Errors appear during deploys and under load.
What I'd do →
- 503 means no ready endpoints for the backend, 502 means the upstream closed or refused
kubectl get endpointsto see readiness gaps- Check pod restarts and OOMKills with
kubectl get pods - Raise
proxy-read-timeoutor fix slow upstreams if you see 504 - Add preStop sleep and graceful shutdown for deploy-time errors
Why → Ingress sends traffic to pod IPs directly, so any pod that is shutting down or unready can cause 5xx.
Interview tip → Memorise the mapping: 502 bad upstream, 503 no upstream, 504 upstream timeout.
More on Services, Ingress and DNS
A Service has no endpoints. How do you find out why?BeginnerWhen do you use ClusterIP, NodePort, LoadBalancer and ExternalName?BeginnerTraffic to a Service works from some pods but times out from others. How do you debug it?AdvancedYou want to expose three HTTP services under one hostname with different paths. How?Intermediateingress-nginx returns 404 for a new host. What do you check?IntermediateA pod cannot resolve `my-svc` but can reach the pod IP. What do you test first?Beginner