Tell me more ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Could someone help me i get the 502 bad gateway every few seconds

The server is running on vps on debian with quadcore and 3g ram

here is the kind of error i can in the nginx log :

2012/07/23 15:06:53 [error] 2908#0: *247 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 81.255.98.253, server: www.acmslt.fr, request: "GET /category/culte/conferences/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "acmslt.fr", referrer: "http://www.google.fr/url?sa=t&rct=j&q=mosqu%C3%A9e%20de%20savigny%20le%20temple%2077&source=web&cd=2&ved=0CFsQjBAwAQ&url=http%3A%2F%2Facmslt.fr%2Fcategory%2Fculte%2Fconferences%2F&ei=OzANUOj0HYrG0QXusf2xCg&usg=AFQjCNHxw6lN8eBnkEOYDh5ONmutLiATHA"

Here is the nginx.conf

user www-data;
worker_processes 4;
events {
        worker_connections 1024;
       }

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

     # Hide the Nginx version number
     server_tokens off;

     # Tweeks
     sendfile on;
     tcp_nodelay off;
     tcp_nopush on;
     keepalive_timeout 5;
     client_body_timeout 10;
     client_header_timeout 10;
     send_timeout 10;
     client_max_body_size 8M;

     set_real_ip_from 127.0.0.1;
     real_ip_header X-Forwarded-For;

     gzip on;
     gzip_disable "MSIE [1-6].(?!.*SV1)";
     gzip_vary on;
     gzip_comp_level 3;
     gzip_proxied any;
     gzip_buffers 16 8k;

     include /etc/nginx/conf.d/*.conf;
     include /etc/nginx/sites-enabled/*;
  }

the website conf in the site available

server {
        listen 8080;
        server_name www.acmslt.fr acmslt.fr;
        location / {
        root /var/www/wordpress;
        index index.php index.html index.htm;
        # Rewrite rules
        if (!-e $request_filename) {
        rewrite ^(.+)$ /index.php?q=$1 last;
       }
       # Security
       # include global/security.conf;
       # W3 Total Cache
       include global/wordpress-w3-total-cache.conf;
       # PHP-FPM
       include global/php-fpm.conf;
       }
} 

then the global/php-fpm.conf

# PHP scripts -> PHP-FPM server listening on 127.0.0.1:9000
location ~ \.php$ {
                   fastcgi_pass 127.0.0.1:9000;
                   fastcgi_index index.php;
                   include fastcgi_params;
                   fastcgi_connect_timeout 60;
                   fastcgi_send_timeout 180;
                   fastcgi_read_timeout 600;
                   fastcgi_temp_file_write_size 1M;
                   fastcgi_intercept_errors on;
                   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                  }

the php-fpm www.conf

[www]
user = www-data
group = www-data
listen = 127.0.0.1:9000
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
chdir = /

and the php-fpm.log

here is what i can see in the php-fpm log

[23-Jul-2012 08:13:26] NOTICE: fpm is running, pid 631
[23-Jul-2012 08:13:26] NOTICE: ready to handle connections
[23-Jul-2012 08:40:04] WARNING: [pool www] child 646 exited on signal 11 (SIGSEGV)         after 1598.101386 seconds from start
[23-Jul-2012 08:40:04] NOTICE: [pool www] child 1354 started
[23-Jul-2012 08:40:04] WARNING: [pool www] child 1354 exited on signal 11 (SIGSEGV) after 0.191254 seconds from start
[23-Jul-2012 08:40:04] NOTICE: [pool www] child 1355 started
[23-Jul-2012 08:40:20] WARNING: [pool www] child 647 exited on signal 11 (SIGSEGV) after 1614.612810 seconds from start
[23-Jul-2012 08:40:20] NOTICE: [pool www] child 1356 started
[23-Jul-2012 08:41:05] NOTICE: Finishing ...
[23-Jul-2012 08:41:05] NOTICE: exiting, bye-bye!
[23-Jul-2012 08:41:05] NOTICE: fpm is running, pid 1937
[23-Jul-2012 08:41:05] NOTICE: ready to handle connections
[23-Jul-2012 08:51:43] NOTICE: Finishing ...
[23-Jul-2012 08:51:43] NOTICE: exiting, bye-bye! 
[23-Jul-2012 08:51:43] NOTICE: fpm is running, pid 2188
[23-Jul-2012 08:51:43] NOTICE: ready to handle connections
[23-Jul-2012 09:01:42] WARNING: [pool www] child 3934 exited on signal 11 (SIGSEGV) after 325.793784 seconds from start
[23-Jul-2012 09:01:42] NOTICE: [pool www] child 3983 started
[23-Jul-2012 09:01:44] WARNING: [pool www] child 2189 exited on signal 11 (SIGSEGV) after 601.533647 seconds from start
[23-Jul-2012 09:01:44] NOTICE: [pool www] child 3984 started
[23-Jul-2012 09:01:48] WARNING: [pool www] child 2190 exited on signal 11 (SIGSEGV) after 605.045174 seconds from start
[23-Jul-2012 09:01:48] NOTICE: [pool www] child 3986 started
[23-Jul-2012 09:01:55] WARNING: [pool www] child 3984 exited on signal 11 (SIGSEGV) after 10.610551 seconds from start

Thanks

share|improve this question
Is it possible that your PHP-FPM might hit the RAM limit? – Christopher Perrin Jul 23 '12 at 14:29
How do i know if it is ? – user1545713 Jul 23 '12 at 15:31
You could jsut watch the RAM on your server. If you consumption (without the cache) grows close to 3 GB you most likely have a RAM problem – Christopher Perrin Jul 23 '12 at 15:40
There are over 75% free ram leaving – user1545713 Jul 23 '12 at 15:43
Seem like it's no memory problem – Christopher Perrin Jul 23 '12 at 15:49

3 Answers

[23-Jul-2012 09:01:55] WARNING: [pool www] child 3984 exited on signal 11 (SIGSEGV) after 10.610551 seconds from start

Your log clearly shows that php-fpm is crashing. This should never happen, but unfortunately not all software is perfect and bug free.

The first thing to do is to update PHP to the latest possible 5.3 or 5.4 release.

share|improve this answer
I am running php 5.3.14 Is it enough ? – user1545713 Jul 23 '12 at 15:30
5.3.15 has been released, but I don't think that's the issue. I suspect you've run into a bug in php-fpm. The hard part will be isolating the cause of the bug. – Michael Hampton Jul 23 '12 at 15:33
i have updated php to 5.4.5 and now i get always 502 error, here the log : *1 connect() failed (111: Connection refused) while connecting to upstream, – user1545713 Jul 23 '12 at 15:51

I got this problem when the path of PHP's PID was wrong.

/etc/php5/fpm/php-fpm.conf

pid = /var/run/php5-fpm.pid
share|improve this answer
/etc/php5/fpm/pool.d/www.conf – Fabricio Elias Costa Jul 24 '12 at 12:34

I updated php to last 5.3 but always 502

Here my /etc/php5/fpm/php-fpm.conf

pid = /var/run/php5-fpm.pid

error_log = /var/log/php5-fpm.log

include=/etc/php5/fpm/pool.d/*.conf
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.