Nginx + PHP5-FPM – Bad Gateway Error

Server Crash

Yesterday I updated a bunch of programs on one of my Ubuntu servers and brought the server crashing to a stop. After the upgrade there were several problems and it took me 4 hours to figure out what was going wrong. I couldn’t have done it without a ton of help from my friend Duke.

Here were the symptoms:

  • The web server was running because I could get to static HTML pages and images but I could not hit PHP pages.
  • PHP pages would return a Bad Gateway Error.
  • The PHP5-FPM service would not start

Here were the fixes that needed to be done:

Changed it from unix socket to TCP socket so it’s now listening on

One of the things that helped troubleshoot the problem was to look in the Nginx error logs (/var/log/nginx/error.log) to see this:

2014/06/23 14:56:05 [crit] 3328#0: *43 connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream, client:, server:, request: “GET / HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php5-fpm.sock:”, host: “”, referrer: “”

This is just a summary so in the future I have a reference. Hopefully it will help others with similar problems.


Leave a Reply

Your email address will not be published. Required fields are marked *

eight − 3 =