PHP-FPM - Error 503 - Attempt to connect to Unix domain socket failed

Solution 1:

This is potentially caused by systemd configuration on Apache, on Centos 7 for example by default the service is configured with :

PrivateTmp=true

Which means it gets its own subdirectory in /tmp visible as /tmp so it can't see files in /tmp added by other programs. The solution would be to not use /tmp for your php-fpm sockets (more secure than setting the above to false).

(I realise that in at least one case a Debian derivative is in use, but it uses systemd too!)

paulie.

Solution 2:

I just had the same problem after updating apache from 2.4.10 to 2.4.24. With old apache the connection to fcgi worked with a socket in /tmp, while the new apache gave error (2)No such file or directory. Moving the socket to /var/run solved the problem.

Looking at the source code for mod_proxy, I found that on newer apache the path should be relative to the one specified as DefaultRuntimeDir. In my configuration, this is set in /etc/apache2/apache2.conf and it also uses some definition from /etc/apache2/envvars.

Solution 3:

change user and group to your current apache user

/etc/php-fpm.d/www.conf 

** user and group must be the same in /etc/http/conf/http.conf

Then execute

chown -R user.user /run/php-fpm/www.conf

** change to your user