I deliberately stopped my Node.js backend on AWS EC2 to see what NGINX does. It returned 502 Bad Gateway.

Full lab with 4 screenshots here: https://blog.sirvickcloud9.online/2026/10/how-i-fixed-nginx-502-bad-gateway-error.html

Setup

EC2 Ubuntu + Node.js on 3000 + NGINX reverse proxy.

Browser -> NGINX -> Node.js (127.0.0.1:3000)

The Key Lesson

502 does NOT mean NGINX is down. It means NGINX cannot get a valid response from upstream.

I confirmed with:

 bash sudo nginx -t # syntax ok - but this does NOT check backend! sudo tail -n 20 /var/log/nginx/error.log # connect() failed (111: Connection refused) while connecting to upstream