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.

Advertisement - Article continues below

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.

Advertisement
Advertisement - Article continues below
Advertisement - Article continues below

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.

Advertisement - Article continues below

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.

Featured Resources

Top 5 challenges of migrating applications to the cloud

Explore how VMware Cloud on AWS helps to address common cloud migration challenges

Download now

3 reasons why now is the time to rethink your network

Changing requirements call for new solutions

Download now

All-flash buyer’s guide

Tips for evaluating Solid-State Arrays

Download now

Enabling enterprise machine and deep learning with intelligent storage

The power of AI can only be realised through efficient and performant delivery of data

Download now
Advertisement
Advertisement

Most Popular

Visit/security/privacy/355155/zoom-kills-facebook-integration-after-data-transfer-backlash
privacy

Zoom kills Facebook integration after data transfer backlash

30 Mar 2020
Visit/security/data-breaches/355173/marriott-hit-by-data-breach-exposing-personal-data-of-52-million
data breaches

Marriott data breach exposes personal data of 5.2 million guests

31 Mar 2020
Visit/security/cyber-crime/355171/fbi-warns-of-zoom-bombing-hackers-amidst-coronavirus-usage-spike
cyber crime

FBI warns of ‘Zoom-bombing’ hackers amid coronavirus usage spike

31 Mar 2020
Visit/data-insights/data-management/355170/oracle-cloud-courses-are-free-during-coronavirus-lockdown
data management

Oracle cloud courses are free during coronavirus lockdown

31 Mar 2020