Nginx 502 Row Error

Source: Internet
Author: User

A machine on the line (which is where the forum is located) has recently appeared frequently 502, and every 100 visits will appear 10 times, which is too high. So I started my 502 troubleshooting trip.

PS aux | grep -C PHP

Result is 200

Netstat-an | grep -C PHP

The result has been under 5, which shows that the php-cgi process is absolutely enough.

View Php-fpm.log

tail -F  /usr/local/php/logs/php-fpm.log

No valuable information

View Nginx error Log

Tail -f/usr/local/nginx/logs/error.log

No valuable information

Feel the problem may be in the Nginx configuration, so online find about nginx.conf configuration instructions, change to change to always solve this difficult 502. (The process continues for more than a week, changed n multiple parameters, because there is no value, so I no longer detailed records, here a simple stroke.) )

A few days later, suddenly brainwave, nginx error log since do not error, that the definition of the log level did not meet the requirements to error, so look for information to modify Nginx error log level (default is Crit)
Please refer to http://mylinux.5d6d.net/thread-1289-1-1.html
Finally found valuable information:

Connect () to Unix:/tmp/php-fpm.socket failed ( One and connecting to upstream

Google, and immediately found a way to solve the problem:

Modify Php-fpm.conf
Put

<value name="backlog">-1</value>

Change to:

<value name="backlog">1024x768</value>

This is because, php-fpm in the case that the backlog is set to 1, the backlog number is unlimited, determined by the operating system, and the operating system is determined by the kernel parameter net.core.somaxconn, my operating system the value of this parameter is set to 262144. The value of this parameter defaults to 128, and I think setting it to 262144 is definitely unreasonable. So, I tried it again.
Do not modify the php-fpm.conf, that is, the backlog value is-1, and then change the net.core.somaxconn to the default value of 128, there is no more 502

This article refers to: http://www.360doc.com/content/15/0923/13/27889159_501013998.shtml

Nginx 502 Row Error

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.