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.
The top three IT pains of the new reality and how to solve them
Driving more resiliency with unified operations and service managementFree 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
Four strategies for building a hybrid workplace that works
All indications are that the future of work is hybrid, if it's not here alreadyFree webinar
The digital marketer’s guide to contextual insights and trends
How to use contextual intelligence to uncover new insights and inform strategiesFree Download
Ransomware and Microsoft 365 for business
What you need to know about reducing ransomware riskFree Download
Building a modern strategy for analytics and machine learning success
Turning into business valueFree Download