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

While upgrading php5-fpm to 5.4.28, my server lost connection with php and returned a 502 bad gateway response.

If you open your /etc/php5/fpm/pool.d/www.conf file, you'll notice that fastcgi is listening to /var/run/php5-fpm.sock. You'll need to grant your webserver privileges to the unix socket by uncommenting the following lines:

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

Alex Ho

Alex is the Lead Developer at NYCEDC working as a front-end/back-end developer and sysadmin. He has a Graphic Design certification from NYU and is a UX practitioner.