HTTP 502 Bad Gateway

A gateway or proxy got an invalid response from the upstream server.

Updated

502
Bad Gateway
5xx Server error
Class
RFC 9110 §15.6.3
Defined in

What does HTTP 502 mean?

A gateway or proxy got an invalid response from the upstream server. You see 502 from Nginx, Cloudflare, load balancers and CDNs when the application server behind them crashed, refused the connection or returned something that is not valid HTTP.

5xx Server error: The request looked valid, but the server failed to fulfil it. The fix is on the server side.

Common causes of a 502 error

  • The application process crashed or is not running (PHP-FPM, Node, Gunicorn).
  • Wrong upstream port or socket in the proxy config.
  • Firewall blocking the proxy from the origin.
  • Origin response headers too large for the proxy buffers.

How to fix 502 Bad Gateway

  • Check that the app server is running and listening on the configured port.
  • Read the proxy’s error log (for Nginx: connect() failed or upstream prematurely closed).
  • Restart the application and check its own logs.

502 and SEO

Like 500 — short incidents are fine, ongoing 502s reduce crawling and indexing.

Example response

HTTP/1.1 502 Bad Gateway

Related status codes

Check which status code a URL returns with the HTTP header checker.

All HTTP status codesSearch the full list of status codes from 100 to 599 with their meanings and SEO impact.
Open the full list

Frequently asked questions

What does status code 502 mean?
502 Bad Gateway: A gateway or proxy got an invalid response from the upstream server.
How do I fix a 502 error?
Check that the app server is running and listening on the configured port. Read the proxy’s error log (for Nginx: connect() failed or upstream prematurely closed).
Does 502 affect SEO?
Like 500 — short incidents are fine, ongoing 502s reduce crawling and indexing.