Knowledge Base

502 Bad Gateway error explained

502 Bad Gateway is an HTTP (HyperText Transfer Protocol) status code. It means that one server has received an invalid response from another. Often, the problem is because of the protocols of two servers, usually an upstream server and a gateway server, for exchanging data conflict with each other.

According to the W3C (World Wide Consortium), the error is defined as the following:

    “The server, while acting as a gateway or proxy, received an invalid response from the upstream server 
 it accessed in attempting to fulfil the request.”

When you get a 502 Bad Gateway status code, the default error message is displayed on a blank white web page with simple black font text.

Much like the 404 Not Found error, the 502 Bad Gateway error can also be customised. More often than not, however, it will be displayed in any of the following ways:

  • Error 502
  • HTTP 502
  • 502 Proxy Error
  • 502 Bad Gateway
  • 502. That's an error.
  • Temporary Error (502)
  • Bad Gateway! Error 502
  • HTTP Error 502 - Bad Gateway
  • 502 Service Temporarily Overloaded
  • 502 Server Error: The server encountered a temporary error and could not complete your request.
  • Bad Gateway: The proxy server received an invalid response from an upstream server.

Possible Causes of HTTP 502 Bad Gateway Errors

Often, the cause of this HTTP error is not localised, which means it has nothing to do with your computer but more to do with the hosting server of the website you are trying to access. In the interest of being thorough, however, here are the following possible causes of a 502 Bad Gateway error code:

  1. The upstream server, or the server that is higher in the hierarchy of servers, is down and cannot be accessed.
  2. The origin server, or the highest server in the hierarchy of servers, is down or cannot be reached.
  3. Multiple users are accessing the site at the same time, and the server has become overloaded.
  4. There are bugs in the site’s associated PHP programming, which is making the site unstable.
  5. There are some issues with your internet browser and it cannot find and access the site or web page.
  6. Your internet gateway or router is unable to communicate or pull content from the origin server, probably because of a firewall.

Easy Ways to Troubleshoot an HTTP 502 Bad Gateway Error

Although an HTTP 502 Bad Gateway error is often an issue outside of your computer, there is still a possibility that you may be able to find a solution to the issue.

Here are some ways you may be able to remedy a 502 error:

  1. Check if the site is down. Confirm that the site is down or it’s just you who can’t access it. Use web tools that would help you check this such as isitdownorjust.me, or isup.me.

    If the site is down, contact the webmaster and inform them about the issue. Chances are they are already trying to fix it, or if they are not yet, they will certainly be grateful for the heads up.

  2. Clear your browser cache. It could just be a cache-related issue. Perhaps your browser unknowingly stored corrupted files stored a copy of the error, or just has too many cached versions of the site and so your browser got confused.

  3. Refresh the page. Press F5 to reload the page or Ctrl + F5 for a hard refresh. Often, a 502 Bad Gateway error is temporary and simply reloading the page could resolve the issue.

    If you are on a Mac computer, click Command key + R to refresh a web page.

  4. Delete your cookies. Your browser could be overloaded with too many cookies, or perhaps it has stored corrupted cookies. To resolve this, you let your browser start fresh and store new cookies.

    If you’re concerned that you may be unable to retrieve important passwords, try deleting the cookies related to the site you’re trying to access first. If that doesn't work, delete the rest of the cookies.

  5. Open new browser sessions. Close all your browser windows and tabs and open new ones. The 502 error has likely has passed but your browser just could not update the status, even though the issue has been resolved in the origin server. A simple browser restart could resolve the issue.

  6. Use another web browser. Perhaps the 502 error is an issue specific to a browser. If this is the case, using another web browser could solve the problem. Popular web browsers you can try are Chrome, Firefox, Internet Explorer, Opera, and Safari.

  7. Restart your computer. Perhaps there are some temporary issues with your computer and it is unable to correctly connect to your network. If this is the case, a basic reboot of your machine might solve the issue. This is especially applicable if all the websites or web pages you visit are returning 502 errors.

  8. Restart your modem or router. It could be that your networking device is the one causing the 502 error. It might be lagging or is just temporarily unstable. A simple reboot of these devices could help resolve the issue.

  9. Contact your ISP (Internet Service Provider). If you get the 502 error message on all the sites you visit, then it is quite probable that your ISP (Internet Service Provider) has failed or is overloaded. If this is the case, contact your Internet provider.

  10. Disable unnecessary plugins. If you’re using a CMS such as WordPress, it might be a good idea to reassess the plugins you have installed in your site and do some “spring cleaning” of some sort. Uninstall and delete the ones you’re not using to free space in your server.

  11. Check your PHP settings. Adjust the memory limit and maximum execution time in your site. This way, it will help minimise overloading, and in turn, downtimes in your server.

  12. Optimise your scripts. Try compressing your CSS and Javascript files. This is to minimise lag times, especially for heavy sites. When a site is too heavy, it sometimes takes too long for it to respond to queries and this sometimes causes 502 errors.

You can also view our other guides for 500 Internal Server error and 503 Service Unavailable error.If you need any further assistance, or if you have any questions, please let us know. We’d love to help!

Did you find this article helpful?

* Your feedback is too short