5xx Server Error
502 Bad Gateway
A gateway or proxy received an invalid response from the upstream server.
Check a URL's HTTP statusWhat it means
Common with CDNs, load balancers, and reverse proxies such as Nginx in front of an application server.
Common causes
- The application server crashed or is restarting.
- The upstream server returned a malformed response.
- Firewall rules block the proxy from reaching the origin.
How to fix it
- Check that the origin server is running and reachable from the proxy.
- Review proxy and origin logs around the time of the error.
- Increase upstream timeouts if the app is slow to start.
Example response
HTTP/1.1 502 Bad Gateway
Content-Type: text/plain; charset=utf-8Worked example
A gateway or server cannot complete an otherwise valid request. Check the origin service and proxy logs, correct the server-side cause, then retry after the service is healthy.
How to read this response
- Find the status line in your browser's Network panel, API client, or server access log.
- Read the response body and headers shown above; headers such as Location, Allow, Retry-After, and WWW-Authenticate explain the next step.
- Use the code's class to orient your diagnosis: informational, successful, redirected, request-related, or server-side.
How to check a status code
Enter a URL in the HTTP Status Checker to see its status code, every redirect hop, and response time. For redirect-heavy pages, the Website Speed Test shows how much time redirects add.
Frequently asked questions
- What it means: HTTP 502
- 502 Bad Gateway: A gateway or proxy received an invalid response from the upstream server.
- Common causes: 502
- The application server crashed or is restarting. The upstream server returned a malformed response. Firewall rules block the proxy from reaching the origin.
- How to fix it: HTTP 502
- Check that the origin server is running and reachable from the proxy. Review proxy and origin logs around the time of the error. Increase upstream timeouts if the app is slow to start.
Defined in RFC 9110.