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.
Related status codes
500 Internal Server Error
A generic server-side error — the server encountered an unexpected condition.
503 Service Unavailable
The server is temporarily unable to handle the request (overload or maintenance).
504 Gateway Timeout
The gateway/proxy did not receive a timely response from the upstream server.