Nginx error stating connection refused to PHP-FPM port

Found it:

In order to specify the port number you would need to edit the "listen =" directive in /etc/php5/fpm/pool.d/www.conf however I discovered that it is theoretically more efficient to allow Nginx to communicate over Unix sockets so I swapped

127.0.0.1:9000

with

/var/run/php5-fpm.sock

That was the first step...

I then had to replace the following lines in my sites configuration file (sites-available/default):

fastcgi_pass 127.0.0.1:9000;

with

fastcgi_pass unix:/var/run/php5-fpm.sock;

And now I am up and running.


If your service (not only PHP-FPM) are listening port, you can determine it by typing sudo netstat -lntp:

# sudo netstat -lntp
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 192.168.16.121:3306     0.0.0.0:*               LISTEN      1427/mysqld     
tcp        0      0 127.0.0.1:11211         0.0.0.0:*               LISTEN      1722/memcached  
tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN      642/smbd        
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      21315/nginx     
tcp        0      0 127.0.0.1:81            0.0.0.0:*               LISTEN      25078/php-fpm.conf)

where you can see that PHP-FPM process with pid 25078 uses 81 port.