What is a 502 bad gateway and how do you fix it?
We explain what this networking error means for users and website owners
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.
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.
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.
- 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.
- 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.
- 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.
- 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.
Preparing for AI-enabled cyber attacks
MIT technology review insightsDownload now
Cloud storage performance analysis
Storage performance and value of the IONOS cloud Compute EngineDownload now
The Forrester Wave: Top security analytics platforms
The 11 providers that matter most and how they stack upDownload now
Harness data to reinvent your organisation
Build a data strategy for the next wave of cloud innovationDownload now