Gunicorn

Nginx 502 Bad Gateway when connecting to Gunicorn socket

critical
Connection ManagementUpdated Nov 20, 2025(via Exa)
Technologies:
How to detect:

Nginx returns 502 Bad Gateway when unable to connect to Gunicorn Unix socket. Root causes include Gunicorn not running, permission denied on socket (errno 13), or connection refused (errno 111)

Recommended action:

Check if Gunicorn is running with ps aux | grep gunicorn. Inspect /var/log/nginx/error.log for connection errors. Test socket directly with curl --unix-socket [socket-path] http://localhost/. Verify socket and directory permissions. Restart both services with sudo systemctl restart nginx