The 502 Bad Gateway error usually happens when there are some network errors between computer and internet severs . This means that a server (not necessarily a web server) acting as a gateway or proxy and received an invalid response from an upstream (or origin) server. In most cases the problem is not with you computer or your internet connection , it's far more likely that it's the website's server instead.
HTTP status code
In essence, if you see a 502 Bad Gateway error, this is an HTTP status code . HTTP status codes are three-digit codes, and are grouped into five different classes. The class of a status code can be quickly identified by its first digit:
- 1xx: Informational
- 2xx: Success
- 3xx: Redirection
- 4xx: Client Error
- 5xx: Server Error
The 502 'Bad Gateway' error is coming from the server , and usually has nothing to do with your PC. It usually happens when you visit a website that uses a relay point, called a proxy server, that keeps data separate from the server hosting the site's main page. If the main server and proxy server don't properly connect due to incorrect Transmission Control Protocol data, your browser determines the proxy, or gateway, to be bad.
Different sites and services will often customize their error messages , both for the sake of them appearing unique, and also help tech-savvy users to better understand the cause of the error.
- 502 Bad Gateway
- 502 Proxy Error
- 502. That's an error
- HTTP Error 502 - Bad Gateway
- 502 Service Temporarily Overloaded
- Bad Gateway: The proxy server received an invalid response from an upstream server
- 502 Server Error: The server encountered a temporary error and could not complete your request
Cause of 502 Bad Gateway Errors
The 502 Bad Gateway Error is an indication that something has gone wrong within the server of your application, as opposed to the client side request. At its heart, the cause is simple, two online servers are having trouble communicating. Often, simply refreshing or reloading the page (Ctrl-F5) will work, but sometimes the problem can persist for days. There are 5 main problems that cause 502 Bad Gateway responses. These include:
Server failure: The gateway receives a negative result if the target server has failed completely. This can occur due to a system crash .
Domain name not resolvable: The domain name is not resolving to the correct IP or it does not resolve to any IP. It is important to note that DNS changes could take same time until they are global fully propagated and active. This is dependant on the TTL, or time to live, defined per record.
Webserver overload: If a webserver reaches its limit, it can't answer any more requests , the gateway then delivers the status code 502 Bad Gateway.
Firewall blocks request: Firewalls can cause errors on both sides of the communication (server and client) with the forwarding of requests.
Browser error: Browser extensions can also sometimes cause errors with the display of a website and generate a 502 error .
How to Fix a 502 Error
- Perform a hard-refresh in your browser. On Macs, this is done by pressing Cmd + Shift + R.
- This problem is due to poor IP communication between back-end computers, possibly including the Web server at the site you are trying to visit. Before analysing this problem, you should clear your browser cache completely.
- If you get this problem for only some of the Web sites you try to visit then it is likely to be a problem at those sites i.e. one of their pieces of equipment is failing/overloaded. Contact the people at those sites.
- If you are surfing the Web and see this problem for all Web sites you try to visit, then either 1) your ISP has a major equipment failure/overload or 2) there is something wrong with your internal Internet connection e.g. your firewall is not functioning correctly. In the first case, only your ISP can help you. In the second case, you need to fix whatever it is that is preventing you reaching the Internet.
- In some cases, this error caused by low computer hard disk space, you can go check the free space of your computer hard disk. If there is really not enough free space left, clean your computer hard disk well.
- Start your browser in Safe Mode. Running a browser in Safe Mode means to run it with default settings and without add-ons or extensions, including toolbars.
- If your web application is configured to listen on a socket, ensure that the socket exists in the correct location and that it has the proper permissions
- Finally, restart your computer/networking equipment. Some temporary issues with your computer and how it's connecting to your network could be causing 502 errors, especially if you're seeing the error on more than one website. In these cases, a restart would help.