What does error 504 mean (for a shared hosting account)? Print

  • 0

In this article we are going to explain the reasons that may cause HTTP error 504 (Gateway Timeout (time out)).

Our shared hosting servers use web server Apache which runs on the back-end and handles the dynamic content (e.g. PHP scripts); and web server Nginx that is used as a front-end proxy. Nginx spits out static content (e.g. JPEG pictures), passes requests for dynamic content to Apache and, when Apache sends the response, returns it to the HTTP client (web browser).
504 Gateway Timeout error means basically the following: Nginx sent a request to Apache and didn’t receive a response within a pre-set time limit.

What can possibly cause 504 error? We may single out the following reasons.

  1. The limit of resource usage is exceeded. For our shared hosting servers there are limits such as on number of processes that run simultaneously, number of MySQL database queries, etc. For more information please read our Acceptable Use Policy, paragraph 10 “Additional acceptable use policy for virtual accounts”.
  2. Web traffic went up. There are so many visitors who create HTTP requests that Apache can’t handle all of them. As a result, the requests are put in queue, the queue extends and eventually the connection times out.
  3. Scripts take too long to execute. It can happen if the scripts are unoptimized, or send queries to other websites, or process complex queries (e.g. a search query with multiple criteria). Sometimes PHP max_execution_time parameter value is too low so increasing the value may be enough to solve the problem. This parameter can be set either in local php.ini file (if you use default (native) PHP version) or in cPanel (Software/Services > Select PHP version > Show PHP Settings).

How to solve the issue and get rid of 504 error?

The best approach is to optimize the code of your website. If you don't know how to do it you should contact developers of the scripts and ask for assistance, or hire a professional programmer. Thus the one-time expenditure on code debugging/optimization will pay off later, making the hosting package upgrade unnecessary (or at least postponing the necessity).
If for some reason code optimization is not an option, you should consider ordering one of our VPS plans or cheap dedicated servers in the USA.


Was this answer helpful?

« Back

Ready to work together towards your success?

We love taking your call.