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

What does this networking error mean for users and website owners?

502 Bad Gateway page that pops up when a website has a connection issue with its server

There are a number of technical problems one can come across when browsing the internet, and browsers will display special codes for some of the most challenging issues.

These codes are unique and relate to specific problems with the connection between your browser and the website you’re trying to access. One of the most common codes you’re likely to see is the 502 error, also known as a bad gateway – this one is rarely caused by a user’s computer or Wi-Fi connection.

Instead, the 502 error is normally indicative of something going awry on the server end of the website you’re trying to access, although it’s impossible from the user’s perspective to see what might have caused this. Typically, this error indicates that there is a communication issue between the gateway and/or the proxy server and the upstream or original server – although that’s not always the case.

You may also encounter the HTTP error 503, which, while similar to the 502 error, normally indicates that the server is unable to handle your browser request.

Causes of 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 also be 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 be a little overzealous and often 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 grind to a halt.

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 serious 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 in order 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

Four cyber security essentials that your board of directors wants to know

The insights to help you deliver what they need

Download now

Data: A resource much too valuable to leave unprotected

Protect your data to protect your company

Download now

Improving cyber security for remote working

13 recommendations for security from any location

Download now

Why CEOS should care about the move to SAP S/4HANA

And how they can accelerate business value

Download now

Most Popular

Cisco acquires container security startup Banzai Cloud

Cisco acquires container security startup Banzai Cloud

18 Nov 2020
macOS Big Sur is bricking some older MacBooks
operating systems

macOS Big Sur is bricking some older MacBooks

16 Nov 2020
46 million Animal Jam accounts leaked after comms software breach

46 million Animal Jam accounts leaked after comms software breach

13 Nov 2020