Nginx 502 Bad Gateway when uploading files

The issue may be caused by PM2. If you're enabled watching, the app will restart on every single file change(and new uploads too). The solution could be disabling watching completely or adding the uploads folder to ignore list. More: https://pm2.keymetrics.io/docs/usage/watch-and-restart/


Try adding the following to your server{} block, I was able to solve an Nginx reverse proxy issue by defining these proxy attributes:

# define buffers, necessary for proper communication to prevent 502s
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;