502 Bad Gateway

A 502 Bad Gateway error means an intermediate server — a reverse proxy, CDN or load balancer — received an invalid response from the upstream origin server it proxies for.

What it means

The user (or crawler) talks to a gateway; the gateway talks to the origin. A 502 means that second hop failed: the origin crashed, timed out, closed the connection or returned something malformed. The gateway itself is usually fine.

Common causes

  • Origin processes crashing or exiting mid-request (deployment bugs, fatal PHP/Python errors).
  • Origin timeouts under load — the gateway gives up before the app finishes.
  • Resource exhaustion: database connection pools, workers, memory.
  • Mismatched configuration after a deploy: wrong port, protocol or upstream name.

Why SEO cares

Search crawlers hitting 502s treat the URLs as temporarily unavailable and retry later — sustained 502s lead to deindexing exactly like 500s. Because 502s often appear in bursts (traffic peaks, deployments), monitoring response codes over time matters more than any single crawl.

Compare 502 frequency against deployment times and traffic curves in your logs — the correlation usually names the culprit.

FAQ

Is 502 a client-side problem?
No. Nothing the browser or crawler can change will fix it. The failure is between the gateway and the origin server.
How do I distinguish 502 from 503 and 504?
502: the origin returned an invalid response. 503: the server declares itself unavailable (often with Retry-After). 504: the origin did not answer in time at all.