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

We explain what this networking error means for users and website owners

502 Bad Gateway page that pops up when a website has a connection issue with its server

Arguably one of the most encountered HTTP error codes, the 502 error is a nuisance to internet users around the world. Chances are that you’ve encountered the 502, also commonly referred to as the ‘502 bad gateway’, at least a few times in your browsing experience.

Similar to other HTTP codes, the 502 aims to warn the user of a particular issue related to the connection between the browser and any website it is attempting to access. However, due to there being at least 40 different server status codes, it might be difficult to remember which code signals what type of problem.

Just like the 503 HTTP error code, the 502 bad gateway usually signifies that the server is currently finding it troublesome to handle the browser request. Fortunately, this means that the fault doesn’t lie with the user attempting to access the site: it’s extremely rare for the 502 error to be triggered by an individual computer or an unstable Wi-Fi connection, which is why these issues can be almost definitely ruled out.

The 502 ‘bad gateway’ error is most often a sign of problems with the server and, in many instances, the gateway or the proxy server might be encountering communication issues with the upstream or original server.

This means that, although the user trying to access the site isn’t to blame, they also cannot do much to remedy the issue, or even identify the root of the problem by themselves. However, those struggling with a 502 error might be able to mitigate the issue by trying out some of our favourite tricks. Read on to find out more about the bad gateway error and how to fix it.

What causes a 502 Bad Gateway error?

Server overload: An overloaded server is one of the most common causes of a 502 error. This is where the server has reached its memory capacity, often activated by an unusually high number of visitors trying to access the same website. This can just be a coincidence, or maybe driven by a big event, but it can also be a targeted DDoS attack.

Request blocked by a firewall: With cyber criminals finding more and more ways to breach corporate networks, firewalls continue to play a key role in stopping them in their tracks. However, a number of firewalls can often go further than you’d like and inadvertently treat a massive influx of legitimate users as an attempted cyber attack. This can often occur with DDoS protection layers, which block requests from content deliver systems and cause the network to grind to a halt.

Faulty programming: Often enough, a glitch or coding error in a website's code might result in requests not being answered correctly, sparking the 502 Bad Gateway error to show up.

Network errors: There are a multitude of potential networking errors that may occur, including potential DNS issues, routing problems, as well as issues relating to your Internet Service Provider (ISP). An ISP, for example, may have decided to block a certain web address.

Server software timeouts: The error can also show for users when a web server takes longer than expected to return a request, and the caching tool reaches its time values. Slower queries can also cause this problem.

How to fix a 502 Bad Gateway error

There are a number of key steps that users can take to attempt to fix a 502 Bad Gateway error.

  1. Refresh your browser: Simply refreshing the browser a few times might be the quickest route to resolving the issue, if not immediately then perhaps after a few minutes. This is because the error may have been caused by a temporarily overloaded server, which could have fixed itself.
  2. Clear your browser cache: It's one of the simplest but most effective ways of overcoming errors such as this, and always one of the best places to start. You'll need to navigate to the history of the web browser you're using and find the option to delete browsing data.
  3. Temporarily disable your firewall: While we wouldn't recommend disabling your firewall, doing so on a temporary basis might be the best way to check whether it's interfering with your attempts to reach a certain site. Some providers, for example, offer DDoS protection, or full proxy services with extra firewalls. You'll normally be able to disable your firewall through the admin console of your security provider.
  4. Check with monitoring sites: If this doesn't work, you could always turn to online services such as Down for everyone or just me? or Down detector. These monitor the web for any outages and allow users to report any problems they may be encountering. If it's an issue affecting not just you, then the chances are others will have reported it, and the more people reporting problems, the more likely it’s a prolonged issue.
  5. Use a VPN to access the site: There are various online virtual private networks (VPNs) such as Hide My Ass and others that can reroute your connection before you access the site. This means you'll be able to figure out whether any issues may have popped up with your ISP, for example, when ISPs block access to certain sites for any particular reason.
  6. Examine web server logs: If this error persists, it may require some further investigation 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

How virtual desktop infrastructure enables digital transformation

Challenges and benefits of VDI

Free download

The Okta digital trust index

Exploring the human edge of trust

Free download

Optimising workload placement in your hybrid cloud

Deliver increased IT agility with the cloud

Free Download

Modernise endpoint protection and leave your legacy challenges behind

The risk of keeping your legacy endpoint security tools

Download now

Most Popular

How to move Microsoft's Windows 11 from a hard drive to an SSD
Microsoft Windows

How to move Microsoft's Windows 11 from a hard drive to an SSD

4 Jan 2022
Microsoft Exchange servers break thanks to 'Y2K22' bug
email delivery

Microsoft Exchange servers break thanks to 'Y2K22' bug

4 Jan 2022
Hired by machines: Exploring recruitment's machine-driven future

Hired by machines: Exploring recruitment's machine-driven future

8 Jan 2022