Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm trying to figure out why I have so many of these error logs:

[error] 1545#0: *713626 connect() failed (111: Connection refused) while connecting to upstream, client: xx.xx.xx.xx, server: www.example.com, request: "GET / HTTP/1.0", upstream: "fastcgi://127.0.0.1:9000", host: "www.example.com"

All of the posts about this error that I've seen result in bad gateway errors, however I've quickly stepped through many pages on the site to try to get the error to pop up, and sure enough, the latest logs show this error with my IP. I never had any issue getting any pages to load, though. What could the issue be?

nginx config:

worker_processes  1;

events {
    worker_connections  1024;
}


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

    sendfile        on;

    keepalive_timeout  65;

    # output compression saves bandwidth
    gzip  on;
    gzip_static on;
    gzip_http_version 1.1;
    gzip_vary on;
    gzip_min_length 1400;
    gzip_comp_level 9;
    gzip_proxied any;
    gzip_types text/plain text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/rss+xml application/atom+xml application/rdf+xml image/png image/gif image/jpeg image/jpg;

    gzip_buffers 16 8k;

    # Disable gzip for certain browsers.
    gzip_disable âMSIE [1-6].(?!.*SV1)â

     server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

 upstream php {
         server unix:/var/run/php-fpm/php-fpm.sock;
                 server 127.0.0.1:9000;
                 }
        include sites-enabled/*.conf;
}

site-specific config:

server {
        server_name www.example.com;
        root /blah/blah/blah;
        index index.php;

        include global/restrictions.conf;
        include global/wordpress.conf;

        location ~ \.php$ {
                include fastcgi.conf;
                fastcgi_intercept_errors on;
                fastcgi_pass php;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                add_header Pragma public;
                add_header Cache-Control "public, must-revalidate, proxy-revalidate";
                log_not_found off;
        }
}
share|improve this question
1  
Maybe your upstream server has a limit on concurrent sessions? Post some configurations could help us solve your issue. –  Lukas Mar 24 '13 at 0:38

1 Answer 1

up vote 2 down vote accepted

You've specified two servers in your upstream block. When one fails, you get the error you are seeing in the logs, and then nginx tries the other one. Since this apparently connects successfully, you are not seeing user-visible errors such as 502 or 504.

I would guess that you converted your PHP-FPM setup from TCP connections to UNIX domain sockets, and forgot to remove the old server 127.0.0.1:9000; line. If the errors bother you, then feel free to do so.

share|improve this answer
    
Excellent. You're correct on your guess. Thank you. –  Alec Sanger Mar 24 '13 at 21:52
    
By the way, your explanation brings up a concern... Since I did accidentally define a second server which was tried after one failed, does that mean that removing the extra server will simply present the error to the client now? In other words, there's still probably an underlying problem that will cause 502s, right? –  Alec Sanger Mar 24 '13 at 21:56
    
Huh? You defined a server that doesn't exist. Removing the invalid definition won't do anything like that. –  Michael Hampton Mar 24 '13 at 21:57
    
@AlecSanger You should check where your php-fpm is actually listening (UNIX socket or port 9000). AFAIK, port 9000 is default in the configs provided by most packaging systems. –  Lukas Mar 24 '13 at 22:25

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.