IT Pro is supported by its audience. When you purchase through links on our site, we may earn an affiliate commission. Learn more

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

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

Among the many server status codes that internet users sporadically run into, a ‘502 bad gateway’ error is one of the most common. Very rarely does an error of this kind indicate an issue with the user or their equipment at home or in the office, although it can be in very rare situations with faults in individual computers or Wi-Fi connections.

More commonly, though, if you’re seeing a ‘502 bad gateway’ error it usually means that there is an issue with the server hosting the website you’re trying to access. Specifically, it is often caused by issues with the gateway, or the proxy server might be encountering communication issues with the upstream or original server.

This is both a good and bad indicator for the user; good because there are no remediating actions to implement or understand, but it’s bad news in the sense that there isn’t much a user can do in order to speed up the connection process. In this case, it’s usually a case of having to wait until whatever issue is affecting the website’s server has been resolved. 

That said, there are a few useful tricks to know that are worth trying in the event they can help restore a connection to the website, and you can read all about them below if you’re interested in trying them for yourself.

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.

Related Resource

The top three IT pains of the new reality and how to solve them

Driving more resiliency with unified operations and service management

Man at his computer next to title card - whitepaper from ServiceNowFree download

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: Refresh your browser: One of the simplest tricks that can help resolve the issue is to refresh the browser a few times. The error can sometimes be displayed as a result of a server becoming overloaded with requests - an issue that is often resolved quickly. Refreshing the browser and sending new requests to the website can help rest the connection and get your browsing back up and running again.
  2. Clear your browser cache: Every browser is different but modern browsers such as Chrome, Firefox, Safari and Microsoft Edge make it easy to find this setting, often located in the browser history section. Clearing the cache is another effective way to overcome 502 bad gateway errors so it’s worth trying, just in case.
  3. Temporarily disable your firewall: We’ll preface this by saying that a firewall should always be active and it is not recommended to disable it for any significant length of time. But in some cases, disabling it and successfully re-attempting to connect to the website may indicate a problem with the firewall’s settings, which can be usually altered 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

Accelerating AI modernisation with data infrastructure

Generate business value from your AI initiatives

Free Download

Recommendations for managing AI risks

Integrate your external AI tool findings into your broader security programs

Free Download

Modernise your legacy databases in the cloud

An introduction to cloud databases

Free Download

Powering through to innovation

IT agility drive digital transformation

Free Download

Most Popular

FCC commissioner urges Apple and Google to remove TikTok from app stores
data protection

FCC commissioner urges Apple and Google to remove TikTok from app stores

29 Jun 2022
Former Uber security chief to face fraud charges over hack coverup
data breaches

Former Uber security chief to face fraud charges over hack coverup

29 Jun 2022
Internet providers look to ease cost of living crisis with cheaper broadband

Internet providers look to ease cost of living crisis with cheaper broadband

29 Jun 2022