Fixing HTTP 502 Bad Gateway Errors in nginx with PHP-FPM
A 502 Bad Gateway error means nginx received no valid reply from its upstream backend, such as PHP-FPM, Node.js, Gunicorn, or a Docker container. Common causes include a stopped or crashed PHP-FPM service, a socket path that changed after a PHP upgrade, mismatched socket permissions, or a backend listening on the wrong port. The article recommends checking the nginx error log and PHP-FPM status, verifying the socket exists and is owned correctly, then restarting the backend and correcting the fastcgi_pass setting. It also distinguishes 502 from 504, where the backend responds but too slowly, and notes that intermittent 502s often stem from crashing workers or a full listen backlog.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in