Error 502 – How to fix it?

Maybe it has happened to you while browsing, or users have reported they can’t access your website. The only thing they see is an Error 502 message. How can you fix error 502?

What is Error 502?

It is a HTTP status code that points to a server communication problem. A server (acting as a proxy) got not response or got an invalid response from another server (origin or upstream server).

To visit a site on the Internet, the browser sends the request to a server connected to the web. The server gets that request and processes it in order to send back the resources you requested, together with an HTTP status code and HTTP header. 

When things work, the HTTP status code is not visible to the users. It’s the way servers communicate with each other. When something fails, the server informs you of the problem through this code.

Error 502 can be displayed also like:

  • HTTP 502
  • 502 Proxy Error
  • 502 Service Temporarily Overloaded
  • 502 Bad Gateway
  • Temporary Error (502)
  • 502 Bad Gateway Cloudflare
  • 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.

What causes Error 502?

  • The origin server can be down, so it can’t be reached.
  • The domain name doesn’t match correctly to the IP address of the host. It can happen due to DNS changes. 
  • Something like CMS security plugins, a firewall, or a DDoS protection system, could block the communication between the origin server and the server, acting as a proxy.
  • It is mostly a network issue. The error occurs on Internet servers. There is a big chance this is not an issue website owners or users have to fix. It must be fixed on the web servers/proxies level.

How to fix Error 502?

First, let’s delete the slight possibilities that the issue is on the user-side:

  • Reload the URL. Connectivity server problems regularly get fixed fast. Just wait a few minutes.
  • Restart your device and network hardware. If Error 502 appears in more websites, temporary conflicts in network devices could be the problem. 
  • Remove browser cache and cookies. Old, corrupted files or cookies stored by the browser could cause Error 502.
  • Restart the browser. There could be a conflict device-browser. Close it perfectly and open a new session.
  • Use browser’s safe mode. This means getting back to default settings, free of add-ons that can be the problem.
  • Use another browser. If the page loads correctly, the problem is on your browser. Just reinstall it.
  • Flush DNS settings. It could be that the IP address you have is not current. Once all the DNS A records are removed, when you require the domain, the browser will search for the DNS A record again, and it will get the newest one with the newest IP address.

Website owner:

  • Test your server. Try a ping test with the IP of the server to see if it responds or not. 
  • Look over server logs. The details about server’s performance will show the problem.
  • Check firewall configurations. The firewall protects your site. But not properly configured, it can directly reject all requests of a content delivery network, considering them an attack to the server.
  • Examine website’s code. Bugs affect the proper answer to content delivery network requests.
  • Wait for DNS modifications to propagate. If you recently changed something, you moved to another hosting server or transferred your site to a different IP address. This can cause Error 502.

DNS propagation explained

  • Ask your hosting provider. Normally, when a server is down or under maintenance, providers fix the problem fast or look for alternatives for you not to lose visitors. But to ask is good in the rare case, they hadn’t realized the problem. 

Leave a Reply

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

Navigation