Apache
Apache users may increase the default timeout value in the httpd.conf file. For example:
# Timeout: The number of seconds before receives and sends time out.
Timeout 99999
Furthermore, increasing the max_execution_time limit in php.ini can also bring positive results:
max_execution_time = 99999;
Save the changes, restart apache, and re-check. The 504 gateway timeout error should be gone if the cause was insufficient request timeout value.
Nginx + FastCGI (php-fpm enabled):
If your VPS utilizes Nginx, try increasing the following values in /etc/nginx/conf.d/timeout.conf
proxy_connect_timeout 99999;
proxy_send_timeout 99999;
proxy_read_timeout 99999;
send_timeout 99999;
In php.ini set :
max_execution_time = 99999;
Change request_terminate_timeout parameter (commented by default) in /etc/php-fpm.d/www.conf (for Debian /etc/php5/fpm/pool.d/www.conf) file:
request_terminate_timeout = 99999;
Add fastcgi_read_timeout variable inside the ‘nginx’ virtual host configuration:
fastcgi_read_timeout 99999;
Add/increase the following values in the ‘http’ section of the /etc/nginx/nginx.conf file:
fastcgi_buffers 8 128k;
fastcgi_buffer_size 256k;
Restart both ‘apache’ and ‘nginx’.
==========================================
If above steps doesn’t work, try this one..
- Open your
nginx.conf
file located in /etc/nginx
directory.
- Add this below piece of code under
http {
section:
client_header_timeout 99999;
client_body_timeout 99999;
fastcgi_read_timeout 99999;
client_max_body_size 32m;
fastcgi_buffers 8 128k;
fastcgi_buffer_size 128k;
Note: If its already present, change the values according.
- Reload Nginx and php5-fpm.
$ service nginx reload
$ service php5-fpm reload
If the error persists, consider increasing the values.
=========================================
Changes in php.ini
Try raising max_execution_time setting in php.ini file (CentOS path is /etc/php.ini):
max_execution_time = 99999;
Changes in PHP-FPM Try raising request_terminate_timeout setting in php.ini file (CentOS path is /etc/php-fpm.d):
request_terminate_timeout = 99999;
Changes in Nginx Config
Finally, add fastcgi_read_timeout variable inside our Nginx virtual host configuration:
location ~* \.php$ {
include fastcgi_params;
fastcgi_index index.php;
fastcgi_read_timeout 99999;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
Reload PHP-FPM and Nginx
service php–fpm restart
service nginx restart