NGINX: connect() to unix:/var/run/php7.0-fpm.sock failed (2: No such file or directory)

Had the same problem. Solution is very easy.

In nginx conf file you are trying upstreaming to

unix:/var/run/php7.0-fpm.sock

Correct path is

unix:/var/run/php/php7.0-fpm.sock


There is a mention about this in the documentation

Nginx communicates with PHP-FPM using a Unix domain socket. Sockets map to a path on the filesystem, and our PHP 7 installation uses a new path by default:

PHP 5 /var/run/php5-fpm.sock

PHP 7 /var/run/php/php7.0-fpm.sock


In Ubuntu 18.04 the problem for me was that it's currently using PHP 7.2, but the sites-available default file has:

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

Updating the version on that line so that it's the 7.2 instead of 7.0 fixed the issue for me.

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


Edit your /etc/php/7.0/fpm/pool.d/www.conf file and find the following line:

listen = 127.0.0.1:9000

And comment it out or replace it with the following:

listen = /var/run/php7.0-fpm.sock