Connection Reset by peer
This error is found in the Nginx error log, in order to better master the abnormal operation of Nginx, it is strongly recommended to add in Nginx global configuration
Error_log Logs/error.log Notice;
In this way, you can record the detailed exception information of Nginx.
Nginx error log will appear connection reset by peer) while reading response headers from upstream, client:1.1.1.1, Server:102.local, R Equest: "get/http/1.1", Upstream: "fastcgi://127.0.0.1:9000
Later repeated checks, found that this is because PHP is running slower, and exceeds the number of seconds php-fpm.conf request_terminate_timeout set.
Request_terminate_timeout is used to set a PHP script to run for the longest time, if the PHP-FPM process Manager is forced to abort the current program, and shut down the fastcgi and Nginx network connection, Then the nginx will appear connection reset by peer error.
In other words, the cause of this error is:
The PHP program runs longer than the value set by Request_terminate_timeout.
In the PHP-FPM environment, there is a setting for this value in the etc/php-fpm.conf of the PHP installation directory, which can be set to a value of 0 or greater.
Tip, there is an max_execution_time in php.ini, which is also used to set the maximum execution time for PHP scripts. However, in the PHP-FPM environment, I found that the Max_execution_time settings are invalid, only request_terminate_timeout have a role.
Summary: Set Request_terminate_timeout to a larger value or 0 to reduce the length of the php script execution resulting in nginx generating connection reset by peer error.
Nginx php fastcgi Connection Reset by peer reasons and solutions