Date Posted: 04-05-2017

We are getting continuous 500 internal server on our php-fpm/fcgi apache server. The log reports the following error


[Day Month xx 10:09:14.269068 2017] [fastcgi:error] [pid 1422] [client xx.xx.xx.xx:59020] FastCGI: incomplete headers (0 bytes) received from server “/usr/lib/cgi-bin/php7-fcgi”
[Day Month  xx 10:09:46.864781 2017] [fastcgi:error] [pid 1690] [client xx.xx.xx.xx:59021] FastCGI: comm with server “/usr/lib/cgi-bin/php7-fcgi” aborted: idle timeout (30 sec)


The reason for this error, php-fpm idle timeout is low(ie 30). If our code/application sends large amount of data to process, it may exceeds idle timeout and leads to 500 error.

Solution:

To fix the error, increase the idle timeout on php-fpm/fcgi configuration.

 

Open the php-fpm configuration file. If you followed our article , the configuration location will be /etc/apache2/conf-enabled/php7.0-fpm.conf

vi /etc/apache2/conf-enabled/php7.0-fpm.conf

Edit the line starts FastCgiExternalServer with idle-timout. If you have a separate configuration for each domain, then you need to update particular domain configuration

FastCgiExternalServer /usr/lib/cgi-bin/php7-fcgi -socket /var/run/php/php7.0-fpm.sock -idle-timeout 300 -pass-header Authorization

 

Restart the apache2 and php-fpm services.

systemctl restart apache2

systemctl restart php7.0-fpm

 

Leave a Reply