Nginx error: connect() failed (111: Connection refused) while connecting to upstream

This morning I was faced with yet another 404 not found page when attempting to login to the Install Nginx on Ubuntu blog.

The logs revealed:

2012/02/15 17:17:33 [error] 13788#0: *5525 connect() failed (111: Connection refused) while connecting to upstream, client: 99.250.236.245, server: installnginxonubuntu.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "installnginxonubuntu.com"

This is not really an Nginx error. The problem is that the backend is not listening on port 9000 or its queue is filled up. I was unable to telnet to 127.0.0.1 9000. Restarting spawn-fcgi fixed this.

I’m not sure if this is a stability issue or configuration issue but will monitor the issue and post results.

Actually, after about 10 seconds of thought, I’m going to switch to PHP-FPM and test the stability.
VN:F [1.9.22_1171]
Rating: 5.0/5 (2 votes cast)
Nginx error: connect() failed (111: Connection refused) while connecting to upstream, 5.0 out of 5 based on 2 ratings

5 Responses to Nginx error: connect() failed (111: Connection refused) while connecting to upstream

  1. What a great blog

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
    • installnginxonubuntu.com

      Thanks

      VN:F [1.9.22_1171]
      Rating: 0 (from 0 votes)
    • Actually I think the problem is besauce you and I installed from source. I recently came across with the same issue. What I could find out, the configuration file fastcgi_params if is installed from source does not contain the line you mentioned. For instance, I have PHP-FPM + Dokuwiki, and if you want to enable redirection to HTTPS based on URL (i.e: login) the location part looks like this:location ~\.php$ { include fastcgi_params; fastcgi_param HTTPS $php_https; # DW checks $_SERVER['HTTPS'] fastcgi_pass 127.0.0.1:9000;In my case I used tcpdump -s0 -l -w -i any port 9000 | strings in order to be sure Nginx was forwarding the requests to PHP-FPM. If you try this you will see the HTTP headers, among them SCRIPT_FILENAME and SCRIPT_NAME, and the status code as well. I normally work with Debian, if you install the package from the repositories you will notice the difference in the file I mentioned. In any case,I like to get it from source, we just keep in mind to add the missing line. Great post !!

      VA:F [1.9.22_1171]
      Rating: +1 (from 1 vote)
  2. Hello,

    I got this when I played with my fpm configuration files, I guess when the max children process are all used, the service close the connection and nginx log this. you need to raise the max children process buy adding some more RAM too :)

    Thank you for this information, find it useful.

    VA:F [1.9.22_1171]
    Rating: -1 (from 1 vote)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>