X
X
X
X

Knowledge Base

HomepageKnowledge BaseProblem of BT-Panel502 error network abnormal

502 error network abnormal

1. The RFC description of the status code
502: Bad Gateway
The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request.
When a server working as a gateway or proxy tried to execute a request, it received an invalid response from the upstream server

504: Gateway Time-out
The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server specified by the URI (eg HTTP, FTP, LDAP) or some other auxiliary server (eg DNS) it needed to access in attempting to complete the request.
Note: Note to implementors: some deployed proxies are known to return 400 or 500 when DNS lookups time out.
When a server working as a gateway or proxy tried to execute a request, it failed to receive a response in time from the upstream server (the server identified by the URI, such as HTTP, FTP, LDAP) or the secondary server (such as DNS).

2. Analysis of specific reasons
Nginx returns 502, which is the response that the service understands
1. nginx and php-fpm cannot connect
2. The link between nginx and php-fpm is abnormally disconnected

The following analysis is performed by nginx+php-fpm, other tools can also perform similar analysis

php configuration file:
http://php.net/max-execution-time
max_execution_time integer
This sets the maximum allowed execution time, in seconds, of the script before it is aborted by the parser. This helps prevent poorly written scripts from using up server resources. The default setting is 30. When running PHP from the command line, it is set to 0 by default.
The maximum execution time will not affect system calls and system operations. For more details, see: set_time_limit

http://php.net/manual/zh/function.set-time-limit.php

bool set_time_limit( int $seconds)
Set the time that the script can run, in seconds. If this setting is exceeded, the script will return a fatal error.

The set_time_limit() function and the configuration command max_execution_time only affect the execution time of the script itself. Any system call such as the use of system() will affect the execution time of the script itself.
The maximum time for script execution of operations, database operations, etc. is not included.

php-fpm.conf file:
request_terminate_timeout

3. Practice test
Test 1: Start nginx, not php-fpm
Phenomenon: nginx server returns 502
Note: nginx cannot connect to php-fpm. When the maximum timeout period of nginx is reached, nginx will return 502 if it has not received a response.

Test 2: Start nginx, start php-fpm

Can't find the information you are looking for?

Create a Support Ticket
Did you find it useful?
(385 times viewed / 0 people found it helpful)

Top