502 Bad Gateway
HTTP response status code 502 Bad Gateway is a server error message that is returned to indicate that it is acting as a proxy or gateway, and it has received an invalid response from the upstream server.
When the 502 Bad Gateway status code is received, the server is first indicating that it is acting as a proxy or gateway for an upstream server. After the HTTP request had been forwarded to the server, an invalid HTTP response was received. The time to resolve this problem cannot be inferred or assumed.
In cases where the origin server returned an HTTP error status code, the same HTTP status code and related information is expected to be returned to the client to provide the most accurate description of the problem.
If the proxy does not receive any HTTP response from the upstream server whatsoever, then a 504 Gateway Timeout status code is more appropriate to be returned.
A 502 Bad Gateway status code can affect the rate at which Googlebot and other crawlers visit the site. If a server is down for a lengthy period while returning a 502 Bad Gateway status code to clients then it can affect the search rankings of the URI and/or site. It is important that if a site is only down temporarily return the 503 Service Unavailable status code instead.
In the example, the client requests a resource and the server responds with a 502 Bad Gateway status code because the server that it attempted to retrieve the resource from returned an invalid HTTP response.
GET /news HTTP/1.1 Host: www.example.re
HTTP/1.1 502 Bad Gateway Content-Type: text/html; charset=UTF-8 Content-Length: 134 <html> <head> <title>Bad Gateway<\title> </head> <body> <p>The server is unreachable at this time.</p> </body> </html>
Apache HttpComponents Core
The 502 Bad Gateway status code is a server error that indicates an upstream server is not functioning as expected.