What is the Bad Gateway Error and How Can it be Resolved?

One of the errors that users of ArvanCloud accelerated and secured websites may encounter is the “website main server” out of access error. This error message indicates that the main server is temporarily unavailable . ArvanCloud displays this message as the default when the original server returns one of the 500, 502, 503 or 504 errors.



A Look at the 502 and 504 Error Codes

HTTP errors related to the 5xx family indicate a server problem that makes it unable to respond. These error codes are sent in Response format in exchange for requests received from the user (browser or edge server CDN).

502 Error Code: Bad Gateway

This error code is displayed to the user when the ArvanCloud edge server receives an invalid response from the website’s main server. This error may occur due to the following reasons:

  • Inaccessibility of the website’s main host server: This could be due to a sudden increase in the amount of traffic sent to the server, increasing overhead and as a result, inaccessibility or loss of connection between the ArvanCloud edge server and the website‘s main host server.
  • Requests getting blocked by the firewall: Requests sent by the ArvanCloud edge server to the website’s main host server are sometimes blocked by a firewall between these servers. This may be caused by high sensitivity DDoS mitigation systems.
  • The requested service or application being blocked on the website’s main host server.


Resolving Error 502

You can take the following actions on the website’s main host server to resolve error 502:

  • Investigate server accessibility using tools such as ping or traceroute
  • Investigate firewall logs by observing unusual drops.


Error 504: Gateway Timeout

This error is displayed whenever the ArvanCloud edge server doesn’t receive a response from the main server in a specified time. This error is displayed for the following reasons:

  • Inaccessibility of or functional problems with the website’s main host server
  • Requests getting dropped due to a firewall on the route between the main web server and the CDN edge server.


Resolving Error 504

You can take the following actions on the website’s main host server to resolve error 504:

  • Adding ArvanCloud IPs to the firewall and server side limitations whitelist
  • Checking to make sure the website's main host server is functioning properly

Although Ping and Trace Route can be used to test the main host server’s accessibility, MTR is a more powerful tool that can provide more information in this regard.


Important Points Regarding “Website Main Host Server” Inaccessibility Error

  • This error message indicates an error on the website’s main server, and is not related to ArvanCloud.
  • Errors on the main servers are mostly temporary and may be displayed for a specific group of users for a few moments before getting resolved.
  • In many cases, the problem could reside with the links connecting the web content host datacenter, and there may be no problems on the website’s main server.
  • This error is not related to security issues, and is often related to large traffic volume from users, communications links, or website accessibility status.
  • Using the default (automatic) setting to establish connections between your website’s main host server and the ArvanCloud edge server while a specific port on your main server is blocked is another important reason why you may encounter the ArvanCloud error when trying to visit the website. According to the request sent by the user, the connection between our servers and your website’s main host server is based on HTTP or HTTPS in automatic mode. The ArvanCloud error will be displayed to users immediately if the 80 (HTTP protocol port number) or 443 (HTTPS protocol port number) port is blocked on your main server and the user sends a request on this port. If you have closed a port on your website’s main host server and are trying to make communications follow a particular protocol (like HTTPS), go to Content Distribution Network (CDN), origin settings, and select your desired protocol from the main server connection protocol (default setting) to resolve this issue, like the following picture. Note that what you specify here will also be applied to activation records. You can read “activation settings on the ArvanCloud user panel” to better understand the activation section.
  • mceclip0.png


Customizing Error Pages in the ArvanCloud Panel

The ArvanCloud panel makes it possible for users to use their customized error pages instead of default ArvanCloud error pages if they so desired. You can go to the ArvanCloud panel and then to “Content Distribution Network (CDN)” and select your preferred mode from “customize errors”.