Symptoms

502 Bad Gateway
nginx/1.xx.x

Cause 1: Backend Service Is Not Running

systemctl status your-app
docker ps
systemctl start your-app

Cause 2: Wrong Port in nginx Config

# Correct
proxy_pass http://localhost:3000;

Cause 3: Wrong Hostname in Docker Environment

# Wrong
proxy_pass http://localhost:3000;

# Correct (use the service name)
proxy_pass http://app:3000;

Check the Error Log

tail -f /var/log/nginx/error.log

Key Points

  • In Docker, use service names instead of localhost
  • The backend not running is the most common cause