A 502 from the ingress: which hop actually failed

502 and 503 fail at different hops and send you to opposite ends of the request. Reading the controller log line that decides it, and why the endpoints list answers a 503 in one command.

Is a 502 from my ingress the app or the ingress?

A 503 usually means the Service has no ready endpoints, so the ingress had nowhere to send the request. A 502 means it did pick a pod and the connection failed or the reply was cut off. The controller log says which and that one line decides whether you look at the ingress or at the application.

The two codes fail at different hops

A request through an ingress makes two journeys: the controller picks a backend pod, then talks to it. A 503 is usually the first one failing, because there was no ready pod to pick. A 502 is the second: a pod was chosen and the conversation went wrong.

Answer the 503 case in one command

If the Service has no ready endpoints, the ingress had nowhere to send the request and nothing in your application will explain it.

kubectl get endpoints <service> -n <namespace>
kubectl get pods -n <namespace> -l <selector> -o wide

An empty list is the whole answer, and the Service with no endpoints is the walkthrough from there.

For a 502, read the controller's own words

The ingress controller logs the failure in more detail than the browser ever sees.

kubectl logs -n <ingress-namespace> <ingress-controller-pod> | grep -E '502|upstream'
  • upstream prematurely closed connection: the pod accepted the request then closed before finishing. The application or its own timeout.
  • connect() failed or connection refused: nothing listening on the port the Service points at. Check targetPort against the container port.
  • upstream timed out: the pod is alive and too slow. Compare the controller's timeout with the real response time under load.

The deploy-shaped version of this

502s that appear only during a rollout usually mean pods are passing readiness before they can really serve, so traffic arrives early and the first requests fail. The rollout looks healthy throughout. Probes that kill healthy pods covers getting readiness honest.

What KubeGraf does with this one

KubeGraf reads the controller log alongside the Service endpoints and the pods behind them, so the no-endpoints case and the bad-conversation case separate before anyone opens a dashboard.

The reference

The full reference: 502 Bad Gateway and 503 from your ingress.

Sources

Read on 25 November 2026. Check the source before you rely on a detail.

Frequently asked questions

What does upstream prematurely closed connection mean?

The pod accepted the request then closed before finishing the reply. That is the application or its timeout rather than the ingress.

Why do I get a 503 with no errors in my app?

A 503 often means the request never reached your app. With no ready endpoints behind the Service the ingress fails the request itself.

Can a readiness probe cause 502s during a deploy?

Yes. Pods that pass readiness before they can really serve take traffic too early and the first requests fail while the rollout looks healthy.

Where do I start, the ingress or the Service?

Check the Service endpoints first because it is one command. An empty list explains a 503 immediately and rules out most of the ingress.

Want this worked for you on your own clusters? Apply for KubeGraf Freemium. Three calendar months by approval, no card and no automatic paid conversion.

Last updated . Try KubeGraf Freemium.