What is a 502 bad gateway and how do you fix it?
What does this networking error mean for users and website owners?
When it comes to broken webpages, 502, 503, 504 and 500 errors are perhaps the most difficult for a user to solve. All of these error codes refer to problems happening at the server end of a connection, and tend to be overly cryptic in what is actually going wrong.
Here we're going to look specifically at the 502 bad gateway error, which is one that most internet users will have encountered at some stage. The good news is that a 502 error is not caused by something going awry with your own equipment or internet connection. Unfortunately, that makes it a little more difficult to fix.
Referred to as an HTTP Status Code, this error indicates to web admins that something has been incorrectly configured on the server. However, there are multiple potential causes of a 502 error and so solving it can be a time-consuming process. What you can ascertain straight away, however, is that a 502 error is related to a communication problem between a gateway or proxy server, and the upstream or origin server.
Below we've pulled together some of the more common reasons for a 502 error, and some potential fixes.
Causes of a 502 Bad Gateway error
Server overload: An error may appear if the website's server has exceeded its operational memory capacity and has overloaded, which is normally associated with an unexpectedly high number of visitors trying to connect to the site - such as a DDoS attack.
Request blocked by a firewall: Firewalls are an essential part of any cyber security policy, however, they can be overzealous determining whether server communication is malicious. This is often a problem with DDoS protection systems, which can block server requests from a content delivery system and cause the network to grind to a halt.
Server overload: A server can crash if it has exhausted its memory, due to a multitude 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, 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, it may require some further investigation 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.
Digitally perfecting the supply chain
How new technologies are being leveraged to transform the manufacturing supply chainDownload now
Three keys to maximise application migration and modernisation success
Harness the benefits that modernised applications can offerDownload now
Your enterprise cloud solutions guide
Infrastructure designed to meet your company's IT needs for next-generation cloud applicationsDownload now
The 3 approaches of Breach and Attack Simulation technologies
A guide to the nuances of BAS, helping you stay one step ahead of cyber criminalsDownload now