Fixed My 502s Only During Traffic Spikes, And The Cause Was Embarrassingly Small
Check teh app service right after a 502:
systemctl status php*-fpm,systemctl status yourapp, ordocker compose ps... if it shows restarts or exited state, read its own logs withjournalctl -u yourapp -n 200ordocker compose logs applmao the real error lives there, not in the proxy log. lmk how it goesnot gonna lie this is driving me nuts spent all weekend on reverse-proxy and im still not done

yeahhh a 502 means the proxy reached out to teh app behind it and got a broken or no response. read the proxy's error log first:
sudo tail -n 100 /var/log/nginx/error.logfor Nginx.connect() failed (111: Connection refused)means nothing is listening;upstream prematurely closed connectionmeans the app crashed or killed teh request mid-way.came here to say exactly this
lol this thread is gold
finally got it working, thanks everyone
yeahhh after reboots and deploys, teh classic cauess are a socket path mismatch (
fastcgi_pass unix:/run/php/...pointing at a socket name that changed), the app not being enabled at boot (systemctl enable yourapp), or a container listening on127.0.0.1inside Docker so teh proxy container can't reach it. Bind to0.0.0.0in the container and use teh service name in teh proxy config.idk man that sounds like bad advice tbh
Reply to this topic
Sign in or create an account to reply.