How to solve 502 Bad Gateway Issues?

What does 502 Bad Gateway mean?

A 502 Bad Gateway indicates that the edge server (server acting as a proxy) was not able to get a valid or any response from the origin server (also called upstream server). KeyCDN returns a 500 Origin Not Reachable if a 502 Bad Gateway occurred.

What does a 502 Bad Gateway error mean

What does 502 Bad Gateway mean?

What are the reasons for 502 Bad Gateway responses?

  • 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 very dependant on the DNS TTL defined per record.
  • Origin server down: The server is not reachable, either because it is down or there is no connectivity to the server given.
  • 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 You Might See a 502 Bad Gateway Error

Based on your web server, you might see a different 502 error. These all mean the same thing, it is only their naming conventions that differ. Here are a few examples of what you might see:

  • “502 Bad Gateway”
  • “HTTP Error 502 – Bad Gateway”
  • “502 Service Temporarily Overloaded”
  • “Error 502”
  • “502 Proxy Error”
  • “HTTP 502”
  • “502 Bad Gateway NGINX”

You can see in greater detail what the error specifically entails by going to your web server’s error log file. All error / diagnostic information is stored in this file making it a valuable resource to check when you need more details about a particular error.  You can locate this file in Apache by going to /var/log/apache2/error.log and in Nginx by going to /var/log/nginx/error.log.

How to solve 502 errors?

  • Check if your FQDN is resolving correctly by using our DNS test tool.
  • Verify if your server is reachable by using a ping test or trace-route.
  • Check your firewall logs if you are seeing unusual drops.
  • Open a support in the KeyCDN dashboard if you can not solve the 502 problem.

One Comment

Leave A Comment?