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

When browsing the internet, there are a number of different error messages that you can encounter. When this happens, your browser will let you know what the problem is by displaying a code that relates to the problem. 

These codes all correspond to particular issues with the connection between the browser and the website that it is attempting to access. One of the most common codes widely seen in day-to-day browsing is the 502 error, also known as a bad gateway, and this one is seldom caused by a user’s computer or Wi-Fi connection.

Instead, the 502 error is typically symptomatic of something askew on the server end of the website you’re attempting to access, although it’s difficult from the user’s perspective to see what might have triggered this. Usually, this error shows that there is a communication problem between the gateway and/or the proxy server and the upstream or original server – though that’s not always the case.

You may also encounter the HTTP error 503, which while comparable to the 502 error, usually signifies that the server is incapable of handling a browser request.

What causes a 502 Bad Gateway error?

Server overload: This is an error that will appear if the website's server has exceeded its operational memory capacity. This will cause an overload which normally is associated with higher-than-expected visitors trying to visit the site. This can occur as a result of something malicious, such as a DDoS attack.

Request blocked by a firewall: Although firewalls are necessary, particularly as cyber attacks are becoming a daily reality for many businesses, they can often be a little overzealous and can mistake mass users coming to a webpage as a hack. This is often a problem with DDoS protection systems, which can block server requests from a content delivery system and cause the network to stop slowly.

Server overload: A server can crash if it has exhausted its memory, either due to a multitude of visitors to a site or because of a DDoS attack.

Firewall blocks a request: A firewall may block communications between an edge server and upstream server. Some DDoS protection systems can over-react and block requests from a content delivery system.

Faulty programming: Sometimes an error in a website's code may mean that requests cannot be answered correctly, prompting this error to show up.

Network errors: DNS issues, routing problems, and ISP related issues can also lead to a 502 Bad Gateway error.

Server software timeouts: This error can also occur when a web server takes more time to complete and a caching tool reaches its timeout values that time. Slow queries can also cause this problem too.

How to fix a 502 Bad Gateway error

Users might find that simply refreshing a browser a few times will fix the issue after a few minutes, if not immediately. The 502 error can be prompted by a temporarily overloaded server, which may have fixed itself.

However, it can be that the server is tackling a more fundamental problem. Users can turn to online services such as Down for everyone or just me? or Down detector, which will give a sense of how many other users are experiencing problems accessing the site. The more people reporting problems, the more likely it’s a prolonged issue.

Users can also turn to services such as Hide My Ass, an online virtual private network (VPN) that can help avoid any issues that may have popped up on the side of the Internet service provider (ISP), such as when the ISP blocks access to certain websites.

If this error happens regularly, 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

How to scale your organisation in the cloud

How to overcome common scaling challenges and choose the right scalable cloud service

Download now

The people factor: A critical ingredient for intelligent communications

How to improve communication within your business

Download now

Future of video conferencing

Optimising video conferencing features to achieve business goals

Download now

Improving cyber security for remote working

13 recommendations for security from any location

Download now

Most Popular

Star Alliance passenger data stolen in SITA data breach
data breaches

Star Alliance passenger data stolen in SITA data breach

5 Mar 2021
I went shopping at Amazon’s till-less supermarket so that you don’t have to

I went shopping at Amazon’s till-less supermarket so that you don’t have to

5 Mar 2021
How to find RAM speed, size and type

How to find RAM speed, size and type

26 Feb 2021