Nginx php fastcgi Connection Reset by peer reasons and solutions

Source: Internet
Author: User
Tags connection reset

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.