n8n errors / Config

502 Bad Gateway (self-hosted, behind reverse proxy)

platform: n8n / category: Config / code: 502

Cause

The reverse proxy (nginx/Caddy) closes the upstream connection before a long-running execution completes, because the default proxy_read_timeout of 60s is too short.

Fix

Set 'proxy_read_timeout 300s; proxy_connect_timeout 300s; proxy_send_timeout 300s;' in the nginx server block and reload. Add WebSocket upgrade headers to prevent editor disconnects. Under load, move from SQLite to PostgreSQL and consider EXECUTIONS_MODE=queue with Redis.

Source thread →

Part of the Automation Error Index — n8n errors: browse all.

Hitting an automation error we have not covered?

AutomateLab builds and debugs n8n, Make, and agent workflows as fixed-scope projects. If something is broken in production, tell us what you are seeing.

Describe the problem