Wednesday, January 24, 2018

What is a 502 bad gateway and how do you fix it?


What does this networking error mean for users and website owners?

There is a good chance that at some point while visiting a website, you have come across a '502 Bad Gateway' error. But what does that actually mean?

In essence, if you see a 502 Bad Gateway error, this is an HTTP status code. This means that a server (not necessarily a web server) acting as a gateway or proxy and received an invalid response from an upstream (or origin) server. It has nothing to do with your desktop, laptop, or smartphone. Neither does it have anything to do with your operating system or browser software.

It is part of a tranche of 5xx server error messages all of which are when a server fails to fulfil a valid request. These errors don’t mean that a server is down, rather than an upstream server and the gateway server couldn’t agree on a protocol for exchanging data. As inter protocols are generally clear, this means that one or both servers have been wrongly or incompletely configured.


Reasons for a 502 Bad Gateway response

There a number of reasons why a user will see a 502 Bad Gateway responses.

Server overload - A server can crash if it has run out of memory, due to lots of visitors on site or a DDOS attack.

Firewall blocks a request - A firewall may block communications between an edge server and upstream server. Some DDoS protection systems can over-react and block requests from a content delivery system.

Faulty programming - sometimes an error in a website’s code may mean that requests cannot be answered correctly, prompting this error to show up.

Network errors - DNS issues, routing problems, and ISP related issues can also lead to a 502 Bad Gateway error.

Server software timeouts - This error can also occur when a web server takes more time to complete and a caching tool reaches its timeout values that time. Slow queries can also cause this problem too.


How to fix a 502 Bad Gateway error

Usually, these errors will go away by themselves and refreshing a web browser page may be all that is needed to get the page you were looking for. If this happens, then the problem was a temporarily overloaded server.

Should it continue to happen, there using a web service such as Down for everyone or just me? will tell you if the problem is more widespread. Use of a third-party proxy such as Hide My Ass can sometimes eliminate problems with a particular ISP (maybe the ISP blocks access to a particular website).

If this error happens regularly, you will need to investigate it in order to find a solution. Examining web server logs at the time of the error occurring will be a good place to start. If you are the owner of the website, you can check your FQDN (fully qualified domain name) is correctly resolving. You can also check a server is reachable via a ping text or traceroute.


EmoticonEmoticon