What is a 502 Bad Gateway and how do you fix it?
We explain what the 502 Bad Gateway networking error means for users and website owners, and some potential steps for fixing it
It is common to see the error ‘502 Bad Gateway’ on websites, often in a basic font or alongside a website’s custom error page. But what does 502 Bad Gateway mean, and how can it be fixed?
This arises as a result of a browser failing to connect to a website’s server, and can be a frustrating error message to receive as its cause is not always made clear. In the meantime, the desired website can be inaccessible which could be particularly difficult if it’s important for work.
What is a 502 Bad Gateway error?
An Error 502 Bad Gateway means there is a problem with the website’s server, rather than your computer, router, or internet connection. It’s very likely that other people visiting the same website are experiencing the same thing.
You can quickly check if there is a problem on your end by visiting a completely different website. If you can do this without any problems, then you can be assured that your connection is fine.
A 502 Bad Gateway error rarely lasts very long and is usually in the process of being solved by the site administrator by the time you see the error message. The ‘Error 502 Bad Gateway’ message has been around for many years, which means websites have become quite skilful at fixing them in a well-timed fashion.
However, if you’re feeling up to it and are curious to see if you can do something yourself, there are several different tactics that may work.
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 driven by a big event, but it can also be a targeted DDoS attack.
Future proofing data infrastructure with more performance, scalability, and resiliency
Dell PowerStoreFree Download
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, several 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 delivery systems and cause the network to stop slowly.
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 is 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: It sounds too simple to be true, but in some cases where the server is overloaded with requests, sending a few more requests by refreshing the browser a few times can sometimes help reset the connection between the device and server, allowing you to resume browsing.
- Clear your browser’s cache: If refreshing the browser a few times doesn’t work then clearing the browser’s cache may help. Major browsers will make this option easy to find within their respective settings menus and most will simply let you enter a query using a search field to find the option. The browser’s cache stores important information that can become corrupted over time, so clearing this and re-attempting to connect to the server may do the trick.
- Temporarily disable your firewall: Not for amateurs, this is one of the more controversial methods on this list. Firewalls should always be active since they help block malicious threats from reaching your device. But, if you’re sure the server is safe to visit, then successfully re-attempting to visit the site with the firewall disabled can indicate there is an issue with the firewall’s settings interfering with network connections. You can adjust the settings in the admin console of the firewall provider.
- Check with monitoring sites: There are a few free websites you can use to determine if other users are also having the same issues as you. Sites such as Down Detector monitor most major websites and provide real-time reports as to whether other users can connect or not. If using one of these sites, it’s helpful to contribute by leaving a report of your own - most don’t even require a registered account to do so. Searching the website’s name on social media platforms such as Twitter can also indicate if others are struggling too.
- Use a VPN: Choosing to re-route your internet traffic through a virtual private network (VPN) can be helpful in determining if your ISP is the issue with the connection to the site. Sometimes ISPs will block access to certain websites and if a VPN allows you to reach it, then it’s most likely being blocked by your provider. Contact their customer service team to remediate the problem in the long term.
- 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.
How long does it take to fix a 502 Bad Gateway error?
Depending on the route cause for your 502 Bad Gateway error, it can take some time to resolve the issue. Many of the solutions such as a quick refresh of the browser, clearing of the cache, or the turning on or off of a firewall or VPN can be done within minutes of the error message being displayed.
If you’re the owner of a website and have recently migrated your domain from one host to another, this can lead to a 502 Bad Gateway error. In this case it could take 24-48 hours for the error to be fixed.
Other causes for a 502 Bad Gateway error include faulty network equipment on your end, which could be resolved quickly or require total overhaul of hardware. It’s impossible to attach a specific time frame to what could be a broad range of issues with equipment.
IT best practices for accelerating the journey to carbon neutrality
Considerations and pragmatic solutions for IT executives driving sustainable ITFree Download
The Total Economic Impact™ of IBM Spectrum Virtualize
Cost savings and business benefits enabled by storage built with IBMSpectrum VirtualizeFree download
Using application migration and modernisation to supercharge business agility and resiliency
Modernisation can propel your digital transformation to the next generationFree Download
The strategic CFO
Why finance transformation propels business valueFree Download