Here is an easy to understand & fix the error connect() to unix:/var/run/php5-fpm.sock failed. No Need to change to listen = 127.0.0.1:9000. Most websites unfortunately do not explain why the error connect() to unix:/var/run/php5-fpm.sock failed appears instead ask to open /etc/php5/fpm/pool.d/www.conf
and change listen = /var/run/php5-fpm.sock
to listen = 127.0.0.1:9000
. Theoretically specking, this is a wrong way to fix as they are not dressing to solve the unix socket issue instead forcing to use TCP/IP. TCP/IP is slower.
connect() to unix:/var/run/php5-fpm.sock failed : Read Our Guides For Installing PHP Applications
It is unlikely to happen if you are reading our guide or script for any deb GNU/Linux. However, it might happen in case we miss few lines. PHP5 UNIX Socket was explained before in another guide. You might read that.
Google ranks which are popular websites, popular websites might not be technically correct. It is quite obvious, why Nginx and PHP5-FPM will throw an error which by default is activated? What exactly happens when we install Nginx and PHP5-FPM?
---
First, we almost never ask to change or check the Nginx user name in /etc/nginx/nginx.conf
file assuming the server OS is Debian or Ubuntu. That socket thing which PHP5-FPM is reporting error, normally Nginx should create it properly and you’ll never get error.
Due to directory permission issues that automatic system fails. That is why we wrote that big guide – Ubuntu Nginx PHP5-FPM UNIX Socket Configuration. That should work in all cases, however we are making it more easy.
connect() to unix:/var/run/php5-fpm.sock failed : Read Our Guides For Installing PHP Applications
None tell that “look at Nginx config file for the user name”. For CentOS and other OS, user of Nginx is not www-data
but nginx
. If we run this command on SSH screen :
1 | cat /etc/nginx/nginx.conf | grep user |
we will get the user
name. For Debian and Ubuntu it is www-data
. Whether you will change nginx
(if your OS repo uses nginx instead of www-data), it depends on you. But, do not try all type of things together. First revert back to the condition you first noticed the error.
We have a file named php5-fpm.conf
at /etc/nginx/conf.d
location with this content :
1 2 3 | upstream php5-fpm-sock { server unix:/var/run/php5-fpm.sock; } |
Quite obviously, if Nginx user is nginx
instead of www-data
, then change the file ownership to www-data:nginx
instead of root:www-data
or www-data:www-data
. There is no /var/run/php5-fpm.sock
file in real.
If you fail to understand what we have written then go to stack overflow and ask the community to help you at the point you are failing pointing towards this guide. If this was not correct, you could not read this webpage!
We dislike changing the default
name of this file – /etc/nginx/sites-available/default
, in that file definitely you have kind of this line :
1 | fastcgi_pass unix:/var/run/php5-fpm.sock; |
Instead of using php5-fpm.sock
if you use php5-fpm.socket
, again it will fail. Another file is at /etc/php5/fpm/pool.d/www.conf
where listening is set to :
1 | listen = /var/run/php5-fpm.sock |
All we have set as php5-fpm.sock
. If you hugely love the word php5-fpm.socket
, then you have to change ALL the words from sock
to socket
. Many web hosts writes mixed words and peoples read and get errors, thats why we said. In the same file (/etc/php5/fpm/pool.d/www.conf
) , you will find :
1 | ;listen.backlog = -1; |
you can remove the comment and use this value :
1 | listen.backlog = 65536; |
Before restarting PHP5-FPM, do a config test :
1 | php5-fpm -t |
then restart the services :
1 | service php5-fpm restart && service nginx restart |
Do exactly what we wrote and tell us if ever fails!
Tagged With connect() to unix: sock failed , connect() to unix://run/php-fpm/www sock failed , how to connect to unix sock , unix:/var/run/php7 0-fpm sock failed (2: No such file or directory) while connecting to upstream , unraid php5-fpm sock