Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

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!
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.
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.