Score:0

502 Bad Gateway, PHP FPM Stop Working

mo flag

I have no idea my server twice a day get 502 bad gateway. I have made lots of tweaks but none of them are working. Here is my dedicated specification

2x E5-2670 0 @ 2.60GHz [32 cores] 32 GB RAM

Here is sample error log

[07-Oct-2022 08:26:19] WARNING: [pool dsimlife-user] child 113207, script '/home/dsimlife/public_html/id1/api-bot.php' (request: "GET /api-bot.php?f=runWork") executing too slow (5.020967 sec), logging
[07-Oct-2022 08:26:19] NOTICE: child 113207 stopped for tracing
[07-Oct-2022 08:26:19] NOTICE: about to trace 113207
[07-Oct-2022 08:26:19] NOTICE: finished trace of 113207
[07-Oct-2022 08:26:24] WARNING: [pool dsimlife-user] child 113218, script '/home/dsimlife/public_html/id1/api-bot.php' (request: "GET /api-bot.php?f=runTask") executing too slow (5.167098 sec), logging
[07-Oct-2022 08:26:24] NOTICE: child 113218 stopped for tracing
[07-Oct-2022 08:26:24] NOTICE: about to trace 113218
[07-Oct-2022 08:26:24] NOTICE: finished trace of 113218

Here is my nginx configuration

user  nobody;
worker_processes 1;
worker_rlimit_nofile 2500;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

pid     /var/run/nginx.pid;
include /usr/local/apps/nginx/etc/modsecurity*.conf;

events {
    worker_connections  1024;
}

error_log /usr/local/apps/nginx/var/log/error_log debug;


http {
    include    mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log /usr/local/apps/nginx/var/log/web.access.log  main;

    sendfile        on;
    #tcp_nopush  on;

    #keepalive_timeout  0;
    keepalive_requests 200;
    keepalive_timeout  130;

    #gzip  on;
    
    client_max_body_size 200M;
    
    # If your domain names are long, increase this parameter.
    server_names_hash_bucket_size 64;
    
    # To hide the version number in headers
    server_tokens off;
    
    include /usr/local/apps/nginx/etc/conf.d/*.conf;
}

Here is my PHP-FPM conf

pm.max_children = 5
pm.start_servers = 0
pm.min_spare_servers = 1
pm.max_spare_servers = 5
pm.max_requests = 20
pm.process_idle_timeout = 10
request_terminate_timeout = 120s

Can anyone tell me what should configuration would be. The main problem is, the server sometime lead to 502 bad gateway where the resource is still fine.

drookie avatar
za flag
You need to look into the nginx error log, not the php-fpm one.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.