PHP program appears 502 bad gateway how to break?

Source: Internet
Author: User
Tags haproxy
PHP program appears 502 bad gateway how to break?

Reply content:

PHP program appears 502 bad gateway how to break?

Confirm that the PHP-FPM process is healthy, and then start with the run environment and adjust the timeout and buffer size configurations.

For example a iptables + haproxy + nginx + PHP-FPM operating environment, Haproxy and Nginx can trigger 502, perhaps your PHP run time exceeded the Haproxy or Nginx timeout settings, Maybe your php output a lot of cookie data and so on.

nginx.conf Reference Adjustment

# 502 probolem solvingfastcgi_connect_timeout 60;fastcgi_send_timeout 180;fastcgi_read_timeout 180;fastcgi_buffer_size 128k;fastcgi_buffers 8 256k;fastcgi_busy_buffers_size 256k;fastcgi_temp_file_write_size 256k;fastcgi_intercept_errors off;

Haproxy.cfg Reference Adjustment

tune.bufsize 131072

PHP will not report 502 must be your front-end Web server (for example nginx , Apache ) reported 502 errors

This error typically occurs when your front-end Web server is unable to connect to the backend CGI ( php-fpm for example)

The further reason is that fpm hangs or is stuck (it will appear when high, memory, or CPU is not enough).

  • 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.