502 bad gateway means that while performing as a proxy or gateway, the server received a non-valid response from the upstream server it accessed in the attempt to fulfill the request being made. A typical pattern of a 502 bad gateway response being displayed includes a web browser client obtains the IP address from a domain name of the website being pinged. The lookup then converts the name to the IP address itself as shown by the DNS servers.
Afterwards a IP socket connection opens up to that IP address and attempts a write of http information back through the socket. The http information stream then sends information back to the web server along with the applicable status code first determined in the protocol. Finally, the stream is extracted for relevant or needed information and the 502 bad gateway is then displayed.
502 Bad Gateway
We once had a Server Administrator friend of ours who claimed that much of the 502 http bad gateway problem was because of bad IP address conversation between background servers, mostly on the server that is hosting the website you are trying to access. He also recommended closing your browser and/or rebooting your computer and verifying your home router firewall is not having issues before assuming it is the website itself. The elements just mentioned can cause you to get the 502 http error also.
If those items don’t resolve it, then best is to contact your ISP as a next step and ensure there is no blockage on their end. This however can usually be ruled out if you can browse to other websites without any problem, thus narrowing a certainty that problem resides with the server hosting the website you are trying to access shows a 502 bad gateway response.