NGINX+PHP-FPM Access 502 Error occurred

Source: Internet
Author: User
Tags php script connection reset

The game backend code is deployed in a nginx+php-fpm manner. Occasionally 502 errors occur when you ask the game.

Nginx error log appears in the following log

2014/07/05 17:20:58 [ERROR] 18431#0: *148739 recv () failed (104:connection reset by peer) while reading response header F Rom upstream, client:192.168.1.56, server:, Request: "Post/gateway.php http/1.1", Upstream: "fastcgi://127.0.0.1:9000" , Host: ""

Now list the troubleshooting ideas

    1. Set the maximum time for PHP script execution in/etc/php.ini max_execution_time =30, here.

    2. Set the PHP-FPM process to process time-out for each process in/etc/php-fpm.conf request_terminate_timeout = 30s

    3. Turn on slow log of PHP in/etc/php-fpm.conf

      request_slowlog_timeout = 1s

      Slowlog =/var/log/php-fpm/www-slow.log


    4. Set in Nginx configuration file nginx.conf

      Fastcgi_connect_timeout 60; Set Nginx and fastcgi server to establish a connection time-out, default is 60 seconds, but this value can not often exceed 75 seconds

Fastcgi_send_timeout 60; To set the time-out for nginx transfer requests to fastcgi server

Fastcgi_read_timeout 60; To set the time-out for FASTCGI server read requests


This article is from the Linux SA John blog, so be sure to keep this source http://john88wang.blog.51cto.com/2165294/1435045

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.