502 Bad Gateway Error - Causes and Fixes

There are many error messages that can occur from time to time while you browse a website or develop it. Some are the fault of the server or its software; Other times, it is an external reason. A 502 error falls under this category.

What is the 502 Error and what does it mean to you and your visitors?

The 500 range server errors primarily tell us that there is a problem between the server and you. The 502 Bad Gateway error could potentially be caused by something in between your browser and the server. In layman terms, this error means that there is a server communication problem between a proxy (or gateway) and the origin server.

Basically, the issue will happen when the upstream (origin) server and the gateway server have a protocol conflict exchanging data, causing your website to flop, usually because of a misconfiguration on the web code.

What are some of the causes for a 502 Bad Gateway error?

There are a few possibilities for this, so let's look at them in a little more detail.

Website Code Errors: This is usually caused by faulty programming, so the errors on your code may be sending multiple requests without getting an adequate response, prompting for a 502. This can sometimes happen during a website update or backup with a simultaneous large stream of visitors.

Server Timeouts: If the queries are very slow, or there is an issue with the server software, then the response time from the server will increase, causing a server timeout. This in turn, can potentially prompt the 502. Server Software issues are most likely to happen during server maintenance.

Server Overload: If your website is overloaded with queries and visitors, you run the risk of running low on memory or swap cache. Extreme CPU usage can also be an option. These are most likely to happen when you  are a victim of a DDOS attack. But it may also happen if your traffic exceeds your server capacity. In this latter case, you are encouraged to upgrade to a more potent server that meats your requirements.

Firewall Security: Usually happens if something triggered a need for DDoS protection. In turn, the server will block requests from reaching the server, causing an interruption between the proxy and your server.

Network Errors: Basically when something, somewhere failed the connection to the server. This could be a DNS issue, routing problem, fallen CDN, interruption by your ISP, among other things. For example, if you use cloudflare and one server dropped, you could get a 502 error caused by the third party server in between you and the website.

Solving the 502 Bad Gateway Error

For the most part, this error will go away right away when you refresh your browser. If necessary, it'll refresh the cache. If the error persists, there may be a server overload and you may have to try to access again in a few minutes.

When the error is very persistent, you should check with "Down for everyone or just me?", a free service that allows to verify if the problem is on your end or the server. If the error is on your end, it could be related to your router, vpn, proxy or ISP. Otherwise, contact us to investigate right away.

If you use a third party proxy like Windscribe, Hot Spot Shield, Hide my Ass, Unlocator or similar; their service may be having trouble connecting you adequately to your server. This can happen because an ISP has blocked your server, suspended service, geo-locking a site, among other reasons. In this case, try turning off your third party service and connect directly to see if that solved it.

Do a hard refresh of your webpage, delete old cache, flush DNS or reboot your computer and router. If all of these fail, and the error happens regularly, you will need to dig deeper into your server logs, keeping track of the times you've encountered the issues, for better resolution.

If you are the owner of the website, you should check if your domain is fully qualified (FQDN) and resolving correctly. It is also a good idea to try to reach the server via ping, traceroute or ftp. If you have trouble reaching your server's cPanel or plesk admin consoles, contact us right away, to check if there is a problem on our end and solve it as soon as possible.

Thank you for choosing us.

  • Email, SSL
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

What is Reverse DNS and PTR and how to configure

Reverse DNS (rDNS) is often times referred to as "reverse DNS lookup" or "reverse DNS...

Out of Space - Cannot access cPanel

This is common for plans that have far exceeded their size quota. You will be presented with an...

Cannot save files or get Access to the Server

This error usually happens when you run out of space.Normally, if you try to access the server...

Limit on Database Size

For VPS-Cloud and Dedicated Servers, Including Managed Servers, there is NO set limit on how many...

How difficult is it to manage a database?

With the proper training, managing a database is very simple.Installation, Setup and Advanced...

Powered by WHMCompleteSolution