← Back to all fixes
Nginx returns 502 Bad Gateway
The Issue
`curl localhost` returns 502 Bad Gateway.
Root Cause
Nginx cannot reach the upstream app. Either the app is down, listening on wrong port, or proxy_pass address is wrong.
How to Fix
Check if your app is running: `systemctl status myapp` or `docker ps`Verify app is listening: `ss -tlnp | grep 3000`Test upstream directly: `curl http://localhost:3000`Read nginx error log: `sudo tail -f /var/log/nginx/error.log`If using Docker: ensure the app container and nginx can reach each other (same network or use host IP)