How you might see the 504 Gateway Timeout error

Different websites may customize the 504 gateway timeout error message. Here are the most common 504 error messages:

    “504 Gateway Timeout”“504 Gateway Time-Out”“504 Gateway Timeout NGINX”“Nginx 504 Gateway Timeout”“HTTP 504 Gateway Timeout”“HTTP 504 Error”“HTTP 504”“Gateway Timeout (504)”

504 Gateway Timeout error on Nginx + FastCGI (php-fpm)

For Nginx + FastCGI (php-fpm), you should try to tweak nginx configuration in this way:

Try raising max_execution_time setting in php.ini file (CentOS path is /etc/php.ini):

max_execution_time = 300

But, you should also change set request_terminate_timeout parameter (commented by default) at www.conf file from PHP-FPM:

pico -w /etc/php-fpm.d/www.conf

Then set the variable to the same value as max_execution_time:

request_terminate_timeout = 300

Now let’s add fastcgi_read_timeout variable inside our Nginx virtual host configuration:

location ~ .php$ { root /var/www/sites/nginxtips.com; try_files $uri =404; fastcgi_pass unix:/tmp/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; fastcgi_read_timeout 300; }

Then restart nginx:

service nginx reload

504 Gateway Timeout error using Nginx as Proxy

For Nginx as Proxy for Apache web server, this is what you have to try to fix the 504 Gateway Timeout error:

Add these variables to nginx.conf file:

proxy_connect_timeout 600; proxy_send_timeout 600; proxy_read_timeout 600; send_timeout 600;

Then restart nginx:

service nginx reload

Tags
blog学术分类

添加新评论

纯文本

  • 不允许使用HTML标签。
  • 自动断行和分段。
  • 网页和电子邮件地址自动转换为链接。

编辑手记和后续补充