cancel
Showing results for 
Search instead for 
Did you mean: 

ERROR 504 - GATEWAY TIMEOUT

ERROR 504 - GATEWAY TIMEOUT

HI All, 

We have configured magento website with cloud-fare. we got 504 error intermittently. How can we fix this issue 

3 REPLIES 3

Re: ERROR 504 - GATEWAY TIMEOUT

A 504 Gateway Timeout error by CloudFlare usually means that CloudFlare isn't able to communicate with your server. 

 

Make sure that your server is not overloaded and CloudFlare IPs are not blocked by your server firewall. 

Re: ERROR 504 - GATEWAY TIMEOUT

Did you try to turn off cloudflare? If the error still persits => That's your server problem

Re: ERROR 504 - GATEWAY TIMEOUT

Here is what you can do to resolve ERROR 504 -GATEWAY TIMEOUT

1.  Clear the browser cache/Magento cache.

Whenever we make any changes to the Magento website, they will not appear unless we clear the application’s cache.

So it’s a mandatory step to first clear the browser cache and the Magento cache.

To clear the Magento cache, (through the Admin Panel)

    1. We go to the Magento admin panel.
    2. Then go to System -> Cache Management -> Flush Cache Storage

For manually clearing the Magento cache:

To clear the cache, we simply delete everything from the var/cache/ directory and then reload the website. Magento keeps its cache in the var/cache/ folder located inside the Magento installation directory.

 

2. Exceeding PHP limits

In a similar way, Magento 504 gateway timeout error occurs due to PHP limits too.

Here, the PHP goes out of memory when the website code base is extremely big.

In such cases, we increase the PHP memory limits in the php.ini file.

To do this,

  1. We update the below values in the php.ini file.

upload_max_filesize:1000M
max_execution_time:18000
memory_limit:2048M
max_input_time:18000
max_input_vars:3000
post_max_size:1000M

2. And then save the php.ini file.

3. Then we restart Apache service

On a CentOS server : service httpd restart
In Ubuntu: service apache2 restart

Moreover, if the customer is using NGINX webserver, we increase the below values in Nginx conf file at /etc/nginx/nginx.conf

fastcgi_buffers 8128k;
proxy_read_timeout 600;
fastcgi_buffer_size 256k;
fastcgi_read_timeout 600;

This resolves the 504 gateway time out error for our customers.

 

3. Fix faulty firewall configurations.

Sometimes a faulty firewall configuration will cause the Magento 504 gateway timeout error. So our Dedicated Engineers ask our customers to check the firewall configuration or disable it temporarily. This can easily isolate the firewall problem.

 

4. Check for any DNS changes

If the customer recently changed host servers or moved the website to a different IP address, this could cause the website to serve its visitors a 504 Gateway Timeout Error page.

The website won’t be up and running until these DNS changes take full effect, which can take a few hours.

So we wait for the completion of the DNS propagation delay.

 

5. High load on the server.

When the store receives more traffic than it can handle, it returns the 504 gateway timeout error in Magento.

So the high load/traffic on the server caused this gateway time out error.

In this case, we ask the customers to check the high load on the server and optimize the server to handle these visitors. This includes service configuration tweaking, adding server resources, etc.

 

6. Locked session

Another most common cause of 504 error is a locked session. It is a built-in feature of Magento that locks the session until the page load is complete.

The side effect of this locked session is that if we launch a very long-running process, the session will remain locked until that completes.

As a result, the website becomes completely inaccessible.

So we verify the issue by opening the site in an incognito window.

To solve this issue we recommend our customers to run long-running Magento processes by command line or scheduled task. We ask them to avoid web browser for such time consuming tasks.