As we know about Nginx that it is an open source HTTP web server software which offers various services like reverse proxying, caching, load balancing, media streaming, and more. You can also use Nginx as a proxy server for email. The main motto behind Nginx is to create the fastest web server with excellence in its work. With its lots of features, the Nginx continuously beats Apache and another web server.

But if you are getting the error of 504 Gateway Time-out on Nginx then here are the few things which can help you to overcome this problem.
  • To remove this error you have to makes changes in both your php.ini file and Nginx.config.file. First, you have to log in as a root user.
  • Now open your php.ini file and find max_ execution_time directive and if not then add following code in it, otherwise you can increase the limit to 300 :
PHP:
max_execution_time = 300
  • Next you have to make change in your PHP-FPM file and add following code into your php-fpm.d file
PHP:
request_terminate_timeout = 300
  • At last, you can have to add fastcgi_read_timeout directive into your Nginx.config file
PHP:
location ~* \.php$ {
    include         fastcgi_params;
    fastcgi_index   index.php;
    fastcgi_read_timeout 150;
    fastcgi_pass    127.0.0.1:9000;
    fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
}
  • Reload Nginx and PHP-FPM through these commands:
Code:
service php-fpm restart
service Nginx restart
  • Now completely reload your Nginx through these commands:
Code:
service Nginx restart
Author
bhawanisingh
Views
2,655
First release
Last update
Rating
0.00 star(s) 0 ratings
Top