All HTTP status codes
5xx Server Error
RFC 9110

502 Bad Gateway

The server, acting as a gateway, received an invalid response from the upstream server.

What it means

HTTP 502 Bad Gateway indicates that a server acting as a gateway or proxy received an invalid or empty response from the upstream server it was trying to access on behalf of the client.

When it's used

Reverse proxies (Nginx, Cloudflare) when the backend application is down, crashed, or returning malformed responses.

Common causes
  • Backend application crashed
  • Backend timeout exceeded proxy patience
  • Backend returned malformed HTTP
  • DNS resolution failure between proxy and backend
  • Backend listening on wrong port
How to fix it
  • Check backend application is running and healthy
  • Verify proxy → backend network connectivity
  • Increase proxy timeout if backend is legitimately slow
  • Check backend logs for crash details
  • Implement health checks and auto-restart
Example response
HTTP/1.1 502 Bad Gateway
Content-Type: text/html

<h1>502 Bad Gateway</h1>
SEO impact

Critical — Googlebot interprets persistent 502s as a site outage and reduces crawl rate.