Bad Gateway and php5-fpm.sock fail

Posted March 7, 2015 4.5k views
PHPGetting Started

I’m totally lost. I had a working droplet, but had to create a new one in conjunction with CloudFlare to shield the IP from DDOS. I took a snapshot of the existing droplet, created a new droplet from the snapshot, set up CloudFlare to point to the IP for the new droplet, and I get Gateway 502 error messages.

Error log shows:
[error] 908#0: *38633558 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client

So at Support’s suggestion, I gave command:
sudo service php5-fpm restart

But no joy. Same error message and gateway error.

Ran command again, and it returned another process number, but still no joy and same error msg about php5-fpm.sock failure

I don’t know what to do or how else to check anything. I really am new to this and SSH. The droplet shows it’s Ubuntu, if that helps. Heck, I don’t even know what tags to use for this request.


  • Let’s try narrowing down the potential problems. After restarting, what’s the status of service php5-fpm status ? If it isn’t running, then post the output of tail /var/log/php5-fpm.log If it is running, let’s make sure it has the correct permissions. What’s the output of ls -lah /var/run/php5-fpm.sock ?

  • Thanks so much for responding. A terrific Digital Ocean engineer got on the problem and managed to sort it all out. I can’t tell you exactly everything he did, as I watched the commands fly by on the console for quite a while, but it did involve stopping/restarting nginx, and stopping/restarting the php5-pfm service a bunch of times. The DDoS attack had really messed everything up, and part of the solution was changing my CloudFlare settings from “high” security to “I’m under attack.” That with all his fixes got my sites back online.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hi, I’m experiencing the exact same problem, not sure how to fix it. I already restart a couple of times service php5-fpm restart.

the ls -lah /var/run/php5-fpm.sock is returning:
www-data www-data 0 Dec 22 22:18 /var/run/php5-fpm.sock

and the status is running.

I already have cloudflare and 5 droplets connected. And I’m getting same error.

This is affecting our current website a lot.

Any help on this?