A 502 means your reverse proxy got the request fine — but the app behind it didn't answer properly. Before touching any config, find out which layer is actually failing. That one habit fixes most 502s in minutes.
The 4 causes that cover almost every 502
What the log says What it usually means
connect() failed (111: Connection refused) The app crashed, is bound to the wrong address, or the port is wrong
upstream prematurely closed connection A worker timed out, or the container was killed for running out of memory
upstream sent too big header Large cookies / auth headers overflow Nginx's default proxy buffers
connect() to unix:/run/php/php8.3-fpm.sock failed (13: Permission denied) The socket file is owned by a different user than Nginx runs as
Step 1 — Read the error log first
sudo tail -n 5 /var/log/nginx/error.log sudo docker ps -a --format "table {{.Names}} {{.Status}} {{.Ports}}"
Enter fullscreen mode
Exit fullscreen mode
The log line tells you the exact failure.…