There are: nginx and tuned php5-fpm, which have successfully worked for themselves for several months, but this afternoon there was a 502 error. Sobno, problem logs standard problem - php5-fpm fell off.

/var/log/nginx/error.log:

2015/10/14 10:33:14 [error] 2122#0: *1 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 88.156.134.5, server: akirocs.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "akirocs.com" 2015/10/14 10:35:55 [error] 2122#0: *6 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 88.156.134.5, server: akirocs.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "akirocs.com" 2015/10/14 10:36:24 [error] 2122#0: *6 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 88.156.134.5, server: akirocs.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "akirocs.com" 2015/10/14 10:36:30 [error] 2122#0: *6 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 88.156.134.5, server: akirocs.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "akirocs.com" 2015/10/14 10:41:48 [error] 2122#0: *13 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 88.156.134.5, server: akirocs.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "akirocs.com" 2015/10/14 10:42:08 [error] 2122#0: *13 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 88.156.134.5, server: akirocs.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "akirocs.com" 2015/10/14 10:42:17 [error] 2122#0: *13 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 88.156.134.5, server: akirocs.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "akirocs.com" 

Yeah. Well, look at php-fpm ...
/var/log/php5-fpm.log :

 [11-Oct-2015 07:39:48] NOTICE: configuration file /etc/php5/fpm/php-fpm.conf test is successful [14-Oct-2015 10:01:43] NOTICE: configuration file /etc/php5/fpm/php-fpm.conf test is successful [14-Oct-2015 10:12:44] NOTICE: configuration file /etc/php5/fpm/php-fpm.conf test is successful [14-Oct-2015 10:20:20] NOTICE: configuration file /etc/php5/fpm/php-fpm.conf test is successful [14-Oct-2015 10:26:50] NOTICE: configuration file /etc/php5/fpm/php-fpm.conf test is successful [14-Oct-2015 10:28:09] NOTICE: configuration file /etc/php5/fpm/php-fpm.conf test is successful 

Strange. We restart everything - it did not help. We verify the socket on which nginx connects to php5-fpm - everything is fine.
We look at phpinfo in the root of the site - it works ...
We look localhost - we receive standard index.html with a code 200 (OK).
Watch the site - error 502.

Conclusion: php works, nginx works, phpinfo successfully reports on successful work ... but when entering the site we get 502 and write to the log by type

 2015/10/14 10:33:14 [error] 2122#0: *1 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 88.156.134.5, server: akirocs.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "akirocs.com" 

Question. What the hell doesn’t work when entering php-fpm website, but does phpinfo at the root of this site work fine? Reverses of commits to the morning version of the site (when it was still working) did not help.

I enclose akirocs.conf just below:

 server { listen 80; charset utf-8; client_max_body_size 128M; root /home/akirocs/akirocs-web/web; index index.php; server_name akirocs.com; location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; try_files $uri =404; } location ~ /\.(ht|svn|git) { deny all; } } 
  • one
    Opened the site, no errors, everything is displayed. - Visman
  • o_o can't be - Roan
  • @Visman, thanks. cleaned the cookies, now everything is ok. it means the code is tupit, not nginx / php. Thank. - Roan

1 answer 1

Understood.
The situation is trivial, but this message can help someone. Nginx terminated the local socket connection after 10 seconds, recording the socket timeout in the logs. By virtue of "locality", the timeout on the local unix socket is usually about 10 seconds, and not 30 as usual. In one of the last commits, a code with indirect recursion was found, as a result of php it hung up until the StackOverflow error was released, but this error drops 20-30 seconds after the script is called. It turns out that nginx did not receive a response in 10 seconds, and terminated the connection, simultaneously telling everyone that php-fpm was not responding, although in fact php-fpm just fell into recursion.

  • in this case, nginx would return 504 - nörbörnën