Nginx + Php5-fpm error: connect() to unix:/var/run/php5-fpm.sock failed

I was getting this error in my error log, after searching for solutions online I stumbled upon this solution that worked for me. I am writing this post for my personal reference, it would be great if someone gets benefited by this.

The issue is socket itself, its problems on high-load cases is well-known. Please consider using TCP\IP connection instead of unix socket, for that you need to make these changes:

in php-fpm pool configuration   ( located at /etc/php5/fpm/pool.d/www.conf

replace listen = /var/run/php5-fpm.sock with listen =

in you Nginx server configuration file /etc/nginx/sites-available/yourdomainname

replace fastcgi_pass unix:/var/run/php5-fpm.sock; with fastcgi_pass;

To make this change take effect, restart php-fpm by

And restart Nginx by