GetNetGoing helps make networks work

Bookmark and Share

Help for HTTP error 502: “Bad Gateway”

This HTTP error occurs when a gateway or proxy1 that exists between you and a server that you are trying to access, received an invalid response from another server that it needed to access (e.g. the website that you are trying to access) in order to fulfill your request. For example, the website that you are trying to access may use a gateway to forward your request to other programs, and if such a program gives an improperly formatted response then the gateway would respond with a HTTP 502 error.

Outline: Symptoms   Cause   What you can do about it  Extra information   Footnotes

Symptoms

Microsoft Windows Update reports HTTP 502 errors with error code 0x80244021 (hexadecimal 80244021).

Apache servers report this as:

Bad Gateway

The proxy server received an invalid response from an upstream server.


(A footnote2 expands on the meaning of “upstream”)

Microsoft IIS web servers may report this as “502 - Web server received an invalid response while acting as a gateway or proxy.” and may provide the following extended codes that give a more specific reason of the error:

Extended code Reason Description
502.1 CGI application timeout. See Microsoft Knowledge Base article 942059: “Error message when you visit a Web site that is hosted on IIS 7.0: “HTTP Error 502.1 - Bad Gateway”
A HTTP 504 error would seem more appropriate for reporting timeouts, since HTTP 502 errors are intended to report invalid responses.
502.2 Error in CGI application. See Microsoft Knowledge Base article 942057: “Error message when you visit a Web site that is hosted on IIS 7.0: “HTTP Error 502.2 - Bad Gateway”
IIS web servers may also report “The specified CGI application misbehaved by not returning a complete set of HTTP headers.” See Microsoft Knowledge Base article 145661 for details.

When Twitter is over capacity, it uses a HTTP 502 response to send its “fail whale” error message:
Twitter is over capacity.  Please wait a moment and try again. For more information, check out Twitter Status

Google servers sometimes report “502 Server Error: The server encountered a temporary error and could not complete your request.”, e.g.:
Google 502 Server Error

Cause

The official description of what causes HTTP 502 errors is
“The server, while acting as a gateway or proxy, received an invalid response from the upstream2 server it accessed in attempting to fulfill the request.”
Unfortunately, the error does not necessarily indicate what was requested, from which “upstream” server, and what the invalid response was.

In the context of Microsoft ISA Servers:

Microsoft Knowledge Base article 938465: “Error message when you try to access Web sites through a downstream server after you enable hotfix 927265 on an upstream server that is running ISA Server 2004 or ISA Server 2006: “502 Proxy Error”

What you can do about it

Since HTTP 502 errors often occur because of programming errors on the server, there is little more that you can do beyond asking the website administrator to fix the problem.

You may also find that the problem disappears if you retry later. You could monitor the website to determine when it returns to service.

Extra information

HTTP 504 errors also arise from gateway/proxy problems, but arise when no response is received from a downstream server.

Footnotes

1 Although “Bad Gateway” is usually reported as the reason for HTTP 502 errors, they can also arise from problems with proxies, which are slightly different from gateways in that they do not act like origin servers.

2 Note that “upstream” here is in the context of the response, so the invalid response came from a server that was “downstream” of the proxy when the request was being sent.

Updated 2 Sep 2011

Copyright (C) 2012 | Site map | Contact us