Nginx + PHP-Fpm 7.1 - 504 Gateway Time-Out

Nginx + PHP-FPM 7.1 - 504 Gateway Time-out

The question is probably why does your backend take so long to respond? Not sure about your usecase but normally it's not user-friendly to wait to long for a response.

To answer your question:

I found this link: https://easyengine.io/tutorials/php/increase-script-execution-time/

Add in /etc/php5/fpm/php.ini

max_execution_time = 300

Set in /etc/php5/fpm/pool.d/www.conf

request_terminate_timeout = 300

Set in /etc/nginx/nginx.conf

http {
#...
fastcgi_read_timeout 300;
#...
}

And in your config:

location ~ \.php$ { 
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_read_timeout 300;
}

And reload services

service php5-fpm reload 
service nginx reload

Nginx / PHP-FPM 504 Gateway Timeout

I almost completely gave up on this! However at the last minute I came up with the answer.

The servers are on Amazon AWS behind a load balancer. The load balancer had the idle-timeout attribute set at 60 seconds. Changing this setting fixed the problem!!

PHP-FPM served by Nginx: 504 Gateway Time-out - nginx

Looks like you need to increase fastcgi_read_timeout in your nginx configuration.



Related Topics



Leave a reply



Submit