How to Solve 502 Bad Gateway nginx error

A 502 Bad Gateway Error means that the web server you’ve connected to is acting as a proxy for relaying information from another server, but it has gotten a badresponse from that other server. It’s called a 502 error because that’s the HTTP status code that the web server uses to describe that kind of error.

What Are the Reasons for 502 Bad Gateway Responses?

There are 3 main culprits that cause 502 Bad Gateway responses. These include:

  1. 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.
  2. Origin server down: The server is not reachable, either because it is down or there is no connectivity to the server given.
  3. Firewall blocks request: A firewall blocks the communication between the edge servers and the origin server. This can also be caused by security plugins of your CMS. Some DDOS protection and mitigation systems might are too overreactive and start blocking requests from our content delivery servers.
How to Fix the 504 Gateway Timeout Error
  1. Retry the web page by clicking the refresh/reload button, pressing F5, or trying the URL from the address bar again. …
  2. Restart all of your network devices. …
  3. Check the proxy server settings in your browser or application and make sure they’re correct.

How to Solve 502 Errors – for Visitors

If you’re a website visitor and experience a 502 Bad Gateway error then there is also a few things you can try to resolve it. Although the primary issue will almost always be the responsibility of the web developer, visitors can try the following:

  • Perform a hard-refresh in your browser. On Macs, this is done by pressing Cmd + Shift + R.
  • Clear your browser cache and delete cookies. Your browser may be holding on to certain files that were saved once you visited the website with a 502 error.
  • Restart your computer/networking equipment
  • Change your DNS servers. If you’ve never changed them in the past you likely still have the default servers assigned to you by your ISP, try using open DNS servers such as Google’s Public DNS.

Leave a Reply

Your email address will not be published. Required fields are marked *