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.
Ideas?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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?
Thanks
Heya,
A 502 Bad Gateway error typically indicates that the gateway/proxy (in your case, Nginx) received an invalid response from the upstream server it tried to access (which seems to be PHP-FPM in your situation).
The error message you’re seeing suggests that Nginx is attempting to connect to PHP-FPM using a Unix socket at /var/run/php5-fpm.sock, but it can’t establish a connection. This could be due to PHP-FPM not running, the socket file not existing, or permission issues.
Here are some steps to troubleshoot the issue:
sudo service php5-fpm status
If it’s not running, try to start it:
sudo service php5-fpm start
Check PHP-FPM Socket File: If PHP-FPM is running, check if the socket file exists at /var/run/php5-fpm.sock. If it doesn’t, there might be a configuration issue.
PHP-FPM Configuration:
/etc/php5/fpm/pool.d/www.conf or similar) has the listen directive set to /var/run/php5-fpm.sock.Nginx Configuration:
/etc/nginx/sites-available/ directory) and ensure that the fastcgi_pass directive points to the correct socket file:fastcgi_pass unix:/var/run/php5-fpm.sock;
sudo nginx -t and if successful, reload Nginx: sudo service nginx reload.File Permissions:
www-data) to access the socket.Logs:
/var/log/nginx/error.log) and the PHP-FPM logs for any additional information.Resources:
pm.max_children setting is too low.Cloudflare:
If you have recently migrated your droplet or changed configurations, ensure that all paths and settings are consistent with the new environment. If you keep hitting a wall, consider reaching out to DigitalOcean support again with the latest details and steps you have taken.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.