*137 connect() failed (111: Connection refused) while connecting to upstream, client:

I know this question has been asked a lot but I’ve spent the last 3 hours on it and I don’t want to keep all the fun to my self.

Long story short I need node js and php on the same droplet, (I need to serve the php as the web client “front end”) and node for the api. I wrote my raw php as a MVC and have the index.php serving from root/public and serving the public ip of the droplet

  1. php7.4-fpm
  2. nginx/1.14.2
  3. node v12.22.1

This is my current server block in nginx:

    server {
        listen 80 default_server;
        listen [::]:80 default_server;
        root /var/www/html/public;

        index index.php index.html index.htm index.nginx-debian.html;


        location / {
                try_files $uri $uri/ =404;
    location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                include fastcgi_params;

        location ~ /\.ht {
                deny all;

And the netstat -plant:

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0    *               LISTEN      28551/nginx: master
tcp        0      0    *               LISTEN      617/sshd
tcp        0      0*               LISTEN      7762/postgres
tcp        0    340       ESTABLISHED 851/sshd: root@pts/
tcp        0      0       ESTABLISHED 717/sshd: root@nott
tcp6       0      0 :::80                   :::*                    LISTEN      28551/nginx: master
tcp6       0      0 :::22                   :::*                    LISTEN      617/sshd

When I try and connect my nginx error log shoots me: *137 connect() failed (111: Connection refused) while connecting to upstream, client:

Do I have to run php -s? Shouldn’t fpm handle spinning the service up?

Any suggestions?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi there @keelingwesley,

It looks like that you’ve set the fastcgi_pass to, however from the netstat output, it looks like that FPM is not listening on that port.

It is possible that your FPM service is not listening on a TCP socket but on a UNIX socket. You can check that in your config file here:


Note: change the 7.4 with the PHP version that you are using

There look for the following line:

listen = /run/php/php7.4-fpm.sock

The listen value needs to match the fastcgi_pass that you’ve specified in your Nginx configuration. This is how Nginx is going to communicate with PHP-FPM.

If you have a UNIX socket specified as the listen value, you need to update your Nginx configuration as follows:

                fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;

For more information on how to setup PHP-FPM with Nginx, you could take a look at this tutorial here:

Let me know how it goes. Regards, Bobby