/ IT

Nginx: connect () to unix: /var/run/php5-fpm.sock failed (13: Permission denied)

The error log of the nginx web server quickly revealed the original error:

$ sudo tail /var/log/nginx/error.log

10.22.2014 07:29:11 [crit] 3057 # 0: * 167 connect () to unix: /var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream,  " 

Nginx could not access the PHP upstream (via PHP-FPM provided) access because the permission was denied.

Fix it

$ sudo emacs /etc/php5/fpm/pool.d/www.conf

Uncomment these lines:

listen.owner = www-data
listen.group = www-data
listen.mode = 0660

And restart the PHP server:

$ sudo php5-fpm restart service

Root cause

But where does this sudden failure came from? Why has Nginx suddenly no longer sufficient rights to access the PHP-FPM socket? The log file of automatical updates are telling more:

2014-06-24 06: 58: 58.192 INFO packages thatwill be upgraded: [...] php-pear php5 php5-cli php5-common php5-curl php5-fpm php5-gd php5 php5-mysql php5-intl-readline 

So in conclusion, automatic security updates that have been downloaded and installed can cause this. It affects some PHP packages - e.g. php5-fpm. After the updates ran through, the owner probably has been changed to root; for whatever reason. Above measures will ensure that the permissions are back to the www-data user, under which most Nginx servers are running.

Nginx: connect () to unix: /var/run/php5-fpm.sock failed (13: Permission denied)
Share this