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

By now, we all know that there are a number of ways to break the internet, and we’re not just talking about celebrities going viral. When something actually disrupts your internet browsing, you’ll be alerted to the issue by a specific code that tells you what it is.

These codes correspond to a particular issue with the connection between the browser and any website it is trying to access. The most common code users encounter in day-to-day browsing is the 502 error, also known as a bad gateway error.

A 502 error is almost never the result of a problem with the user's computer or their Wi-Fi, but instead is a symptom of something going askew on the server end of the website.

As such, it’s quite difficult to see what has triggered a 502 from the user’s perspective. Often, the error shows when there is a communication issue between the gateway or the proxy server with the upstream or original server.

502 is comparable to the HTTP error ‘503’ code, which usually signifies that the server is unable to handle the browser request.

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

The definitive guide to warehouse efficiency

Get your free guide to creating efficiencies in the warehouse

Free download

The total economic impact™ of Datto

Cost savings and business benefits of using Datto Integrated Solutions

Download now

Three-step guide to modern customer experience

Support the critical role CX plays in your business

Free download

Ransomware report

The global state of the channel

Download now

Most Popular

What are the pros and cons of AI?
machine learning

What are the pros and cons of AI?

8 Sep 2021
Citrix mulling potential sale after tumultuous 2021
mergers and acquisitions

Citrix mulling potential sale after tumultuous 2021

15 Sep 2021
Zoom: From pandemic upstart to hybrid work giant
video conferencing

Zoom: From pandemic upstart to hybrid work giant

14 Sep 2021