$ -weight: 500;">systemctl -weight: 500;">status nginx
-weight: 500;">systemctl -weight: 500;">status nginx
-weight: 500;">systemctl -weight: 500;">status nginx
nginx -t
-weight: 500;">systemctl -weight: 500;">restart nginx
nginx -t
-weight: 500;">systemctl -weight: 500;">restart nginx
nginx -t
-weight: 500;">systemctl -weight: 500;">restart nginx
-weight: 500;">curl -I http://127.0.0.1:3000
-weight: 500;">curl -I http://127.0.0.1:3000
-weight: 500;">curl -I http://127.0.0.1:3000
Connection refused
tail -100 /var/log/nginx/error.log
tail -100 /var/log/nginx/error.log
tail -100 /var/log/nginx/error.log
connect() failed
upstream timed out
no live upstreams
# PM2
pm2 -weight: 500;">restart all
pm2 logs --lines 50 # Systemd
-weight: 500;">systemctl -weight: 500;">restart myapp
journalctl -u myapp -n 50 --no-pager # Docker
-weight: 500;">docker ps -a
-weight: 500;">docker -weight: 500;">restart my-container
-weight: 500;">docker logs my-container --tail 50
# PM2
pm2 -weight: 500;">restart all
pm2 logs --lines 50 # Systemd
-weight: 500;">systemctl -weight: 500;">restart myapp
journalctl -u myapp -n 50 --no-pager # Docker
-weight: 500;">docker ps -a
-weight: 500;">docker -weight: 500;">restart my-container
-weight: 500;">docker logs my-container --tail 50
# PM2
pm2 -weight: 500;">restart all
pm2 logs --lines 50 # Systemd
-weight: 500;">systemctl -weight: 500;">restart myapp
journalctl -u myapp -n 50 --no-pager # Docker
-weight: 500;">docker ps -a
-weight: 500;">docker -weight: 500;">restart my-container
-weight: 500;">docker logs my-container --tail 50
upstream backend { server 127.0.0.1:3000; # Use IP, not 'localhost' keepalive 32;
} server { location / { proxy_pass http://backend; proxy_read_timeout 90s; # Add this if timing out proxy_connect_timeout 10s; }
}
upstream backend { server 127.0.0.1:3000; # Use IP, not 'localhost' keepalive 32;
} server { location / { proxy_pass http://backend; proxy_read_timeout 90s; # Add this if timing out proxy_connect_timeout 10s; }
}
upstream backend { server 127.0.0.1:3000; # Use IP, not 'localhost' keepalive 32;
} server { location / { proxy_pass http://backend; proxy_read_timeout 90s; # Add this if timing out proxy_connect_timeout 10s; }
}
nginx -t && -weight: 500;">systemctl reload nginx
nginx -t && -weight: 500;">systemctl reload nginx
nginx -t && -weight: 500;">systemctl reload nginx
# Check memory
free -h # Check disk space (full disk = crash)
df -h # Check CPU
top -bn1 | head -20
# Check memory
free -h # Check disk space (full disk = crash)
df -h # Check CPU
top -bn1 | head -20
# Check memory
free -h # Check disk space (full disk = crash)
df -h # Check CPU
top -bn1 | head -20
502 Error
├── -weight: 500;">curl 127.0.0.1:PORT → Connection refused?
│ └── App is down → Check app logs → Restart app
├── -weight: 500;">curl works fine?
│ └── Nginx config issue → Check proxy_pass → nginx -t
└── Intermittent 502? └── App overloaded → Add proxy_read_timeout → Scale up
502 Error
├── -weight: 500;">curl 127.0.0.1:PORT → Connection refused?
│ └── App is down → Check app logs → Restart app
├── -weight: 500;">curl works fine?
│ └── Nginx config issue → Check proxy_pass → nginx -t
└── Intermittent 502? └── App overloaded → Add proxy_read_timeout → Scale up
502 Error
├── -weight: 500;">curl 127.0.0.1:PORT → Connection refused?
│ └── App is down → Check app logs → Restart app
├── -weight: 500;">curl works fine?
│ └── Nginx config issue → Check proxy_pass → nginx -t
└── Intermittent 502? └── App overloaded → Add proxy_read_timeout → Scale up
process.on('unhandledRejection')
pm2 -weight: 500;">restart --max-memory--weight: 500;">restart 512M - Your Node.js/Python/PHP app has crashed
- Wrong upstream port configured
- App is binding to localhost but Nginx is trying 127.0.0.1 (or vice versa)
- App is overloaded and not responding in time - App crashed due to unhandled promise rejection — add process.on('unhandledRejection')
- Port mismatch — app on 3001 but Nginx pointing to 3000
- App bound to 0.0.0.0 but Nginx using localhost — use 127.0.0.1 everywhere
- Memory exhaustion — app OOM killed, use pm2 -weight: 500;">restart --max-memory--weight: 500;">restart 512M