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

When browsing the internet, there are a number of different error messages that you can encounter. When this happens, your browser will let you know what the problem is by displaying a code that relates to the problem.

These codes all correspond to particular issues with the connection between the browser and the website that it is attempting to access. One of the most common codes widely seen in day-to-day browsing is the 502 error, also known as a bad gateway, and this one is seldom caused by a user’s computer or Wi-Fi connection.

Instead, the 502 error is typically symptomatic of something askew on the server end of the website you’re attempting to access, although it’s difficult from the user’s perspective to see what might have triggered this. Usually, this error shows that there is a communication problem between the gateway and/or the proxy server and the upstream or original server – though that’s not always the case.

You may also encounter the HTTP error 503, which while comparable to the 502 error, usually signifies that the server is incapable of handling a browser request.

What causes a 502 Bad Gateway error?

Server overload: This normally occurs when a website gets far more traffic than it can handle. When a website’s server has been oversaturated, and it reaches its memory capacity, it’ll cause an overload, and it’s normally tied with an unusually high number of visitors trying to access the website at once. While it could just be coincidental, or driven by an event, it can also be the result of a 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

Virtual desktops and apps for dummies

An easy guide to virtual desktop infrastructure, end-user computing, and more

Download now

The total economic impact of optimising and managing your hybrid multi-cloud

Cost savings and business benefits of accelerating the cloud journey

Download now

A buyer’s guide for cloud-based phone solutions

Finding the right phone system for your modern business

Download now

What’s next for the education sector?

A new learning experience

Download now

Most Popular

KPMG offers staff 'four-day fortnight' in hybrid work plans
flexible working

KPMG offers staff 'four-day fortnight' in hybrid work plans

6 May 2021
Hackers use open source Microsoft dev platform to deliver trojans
Security

Hackers use open source Microsoft dev platform to deliver trojans

14 May 2021
How to move Windows 10 from your old hard drive to SSD
operating systems

How to move Windows 10 from your old hard drive to SSD

30 Apr 2021