• Hi.

    I’ve been trying to upgrade my server from a single-site to a multi-site (eventually with distinct domains). I followed the directions from the codex:
    https://codex.www.ads-software.com/Nginx

    Which use php5-fpm. I installed fpm, but something is going wrong and it doesn’t seem to be running no matter that I restart it.

    The error in /var/log/nginx/error.log is:

    2012/06/20 21:28:30 [error] 3391#0: *21 connect() failed (111: Connection refused) while connecting to upstream, client: <my home ip>, server: *.<mysite>.com, request: "GET /tag/pdx/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.<mysite>.com"

    My nginx.conf includes:

    # Upstream to abstract backend connection(s) for PHP.
            upstream php {
    #               server unix:/tmp/php-fpm.sock;
                    server 127.0.0.1:9000;
            }

    and my /etc/php5/fpm/pool.d/www.conf includes:

    listen = 127.0.0.1:9000
    ;listen = /tmp/php-fpm.sock

    I have also tried commenting out the port options and uncommenting the socket options and restarting the nginx and php-fpm servers, to the same effect (with the relevant change to the error message.

    Now here’s where it get’s funky.
    using the command: sudo netstat -tlpn | grep :9000 (found after much googling)
    Shows:
    tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 3454/php-fpm.conf)
    Which implies to me that fpm is alive and listening. Any ideas?? I’ve been working on this for a week!!

Viewing 7 replies - 16 through 22 (of 22 total)
  • Thread Starter uglyelf

    (@uglyelf)

    Well we have figured out something. When nginx wasn’t returning from a restart, what I called hanging, I could still reach mysite.com/readme.html, so nginx was up, and maybe just stuck waiting for fpm to return? Of course then it wasn’t actually shutting down so when I tried to restart the server it would return without problems from stopping, but still say a server was running when I started it again.

    That said, I don’t know how to connect to it over telnet

    from the server, “telnet 127.0.0.1:9000” just returns with connection refused.

    When nginx wasn’t returning from a restart, what I called hanging, I could still reach mysite.com/readme.html, so nginx was up, and maybe just stuck waiting for fpm to return?

    No, nginx doesn’t care about fpm. Nginx may not have been closed when you type sudo service nginx stop. That’s why it can not start another instance of nginx and it just hangs. I may be wrong. You can check this by typing ps aux | grep nginx or pgrep nginx, just after issuing sudo service nginx stop. If nginx still runs, then the previous command did not work and the next command (sudo service nginx start) hangs up the server. That’s why, when you reboot the server, nginx still restarts.

    Additional questions to troubleshoot further –

    – As you can not connect via telnet, can you please double check if fpm is still listening *only* to a port (I remember you mentioned you tried both socket and port. You may have forgotten to switch to port or enabled both. Just my guess. Sorry about asking this, if fpm is already listening to a port.)

    – Can you please double check at /var/lock/ (or whatever the directory) to see, if the socket for php-fpm is *not* there (as I’ve been assuming, fpm is set to listen to a port).

    – Did you check if the content of fastcgi_params file is correct?

    – Does your server have updated packages (especially php5-fpm)? If not, you may want to do sudo apt-get update && sudo apt-get upgrade. It could be a bug with php5-fpm (as nothing reaches php5-fpm and the connection is currently being closed before reaching)

    Thread Starter uglyelf

    (@uglyelf)

    I’m still using the fastcgi_params file you posted, as well as the php-fpm.conf.

    Just after stopping nginx, sudo service nginx stop returns: <myserver> 3635 0.0 0.2 6080 660 pts/1 S+ 18:30 0:00 grep --color=auto nginx so I think that means it is still running and not shutting down properly. I wish there was something in the error log.

    I know I found it on google before, but I can’t refigure out how to check if fpm is listening over a port. Not feeling very smart right now.

    It’s OK to ask about the port vs socket. I’m just trying the port. There is nothing in the socket.

    Yup. Everything is super updated. Just ran update and upgrade again, 0 changes.

    I can’t refigure out how to check if fpm is listening over a port.

    using the command: sudo netstat -tlpn | grep :9000 (found after much googling)
    Shows:
    tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 3454/php-fpm.conf)

    <myserver> 3635 0.0 0.2 6080 660 pts/1 S+ 18:30 0:00 grep –color=auto nginx

    It actually means that nginx has stopped. So, starting Nginx seems to be an issue in your server.

    But, I don’t see any further ideas to troubleshoot. Someone else might help you in this regard.

    I was experiencing a similar issue and the problem was in the following file:

    /etc/php5/fpm/pool.d/www.conf

    I had the following line:

    listen = /tmp/php5-fpm.sock

    Which I changed as follows:

    listen = 9000

    And that fixed the problem for me. Might work for you too.

    Thread Starter uglyelf

    (@uglyelf)

    Thanks for trying Ashleykza. I’d already tried that. My nginx conf and https://www.conf match for their listening ports. ??

    Believe me, I’m up for trying anything at this point. So keep the suggestions coming. ??

    Did you ever get this solved? I’m having the same problem when load is high. Seems to me that the issue is unclosed file handles (if using sock-file) or some connection limit (using tcpip).

Viewing 7 replies - 16 through 22 (of 22 total)
  • The topic ‘502 error caused by connection refused: (upstream fastcgi, etc)’ is closed to new replies.