nginx + php-fpm70 getting 502 bad gateway

General Tech Bugs & Fixes 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

I'm Getting 502 bad gateway error in one of my magento2 site.

Here are my configuration files.

nginx.conf configuration file

    user  nginx;
worker_processes 4;
worker_rlimit_nofile 100000;
pid /var/run/nginx.pid;

events {
        use epoll;
#        worker_connections 1024;
    worker_connections 10240;
        multi_accept on;
}

http {
        include /etc/nginx/mime.types;
        default_type  application/octet-stream;
        access_log off;
        error_log /var/log/nginx/error.log warn;
        rewrite_log on;

    access_log  /var/log/nginx/access.log main buffer=32k flush=300;

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        autoindex off;
        server_tokens off;
        port_in_redirect off;

        open_file_cache max=10000 inactive=5m;
        open_file_cache_valid 2m;
        open_file_cache_min_uses 1;
        open_file_cache_errors on;

        types_hash_max_size 4096;

     client_header_buffer_size 16k;
     large_client_header_buffers 4 32k;

        fastcgi_send_timeout 3600;
        fastcgi_read_timeout 3600;
        fastcgi_buffers 8 256k;
        fastcgi_buffer_size 256k;
        fastcgi_connect_timeout 3600;

############
        client_max_body_size 1024M;
        client_body_buffer_size 128k;
        server_names_hash_max_size 1024;

        client_body_timeout 300;
        client_header_timeout 300;
    keepalive_timeout 600;
        keepalive_requests 100000;
        send_timeout 60;
        server_names_hash_bucket_size 128;

        gzip on;
        gzip_comp_level 6;
        gzip_http_version 1.0;
        gzip_proxied any;
        gzip_min_length 1100;
        gzip_buffers 16 8k;
        gzip_types any;
        gzip_types text/plain text/css application/octet-stream application/json application/x-javascript application/javascript text/xml application/xml application/xml+rss text/javascript text/x-javascript font/ttf application/font-woff font/opentype application/vnd.ms-fontobject image/svg+xml;

        gzip_disable “msie6”;
        gzip_vary on;

        include /etc/nginx/conf.d/*.conf;
}

php-fpm configure file

[domain.com.com]
listen = /var/run/php/domain.com-fpm.sock
listen.allowed_clients = 127.0.0.1

listen.owner = nginx
listen.group = nginx

user = domain_live
group = domain_live

; Choose how the process manager will control the number of child processes.
pm = dynamic
pm.max_children = 150
pm.start_servers = 60
pm.min_spare_servers = 50
pm.max_spare_servers = 90
pm.max_requests = 500

pm.status_path = /status

slowlog = /var/www/www.domain.com.com/logs/php-fpm-www-slow.log
rlimit_core = unlimited
php_admin_value[error_log] = /var/www/www.domain.com.com/logs/php-fpm-www-error.log
php_admin_flag[log_errors] = on

; Set session path to a directory owned by process user
php_value[session.save_handler] = files
php_value[session.save_path]     = /var/www/www.domain.com.com/application/var/session
php_value[soap.wsdl_cache_dir]  = /var/lib/php/wsdlcache

Getting below error logs

php-fpm error logs

WARNING: [pool domain.com] child 4314 exited on signal 11 (SIGSEGV - core dumped) after 4556.304032 seconds from start
NOTICE: [pool domain.com] child 6422 started

nginx error logs

2018/05/18 13:28:02 [error] 4247#4247: *1460 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 1.2.3.4, server: www.domain.com, request: "GET /checkout/cart/ HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/domain.com-fpm.sock:", host: "www.domain.com.com", referrer: "https://www.domain.com.com/customer/account/login/"

Please help to resolve this issue. As i'm already tried multiple ways to resolve issue but didn't get the success.

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.