Fix n8n 'Connection Lost' and Webhook URLs Behind a Proxy
Description and use
When n8n is behind a reverse proxy, webhook URLs expose localhost and the internal port, and the editor shows a persistent "Connection lost" badge. Setting N8N_WEBHOOK_URL, configuring WebSocket support in the proxy, and setting N8N_PROXY_HOPS resolve the issue.
Problem
When n8n is placed behind a reverse proxy, the editor shows a persistent "Connection lost" badge and webhook URLs contain localhost or the internal port, making them unusable from outside.
Outcome
After applying the environment variable and proxy configuration changes, webhook URLs no longer expose localhost or the internal port, and the editor’s live connection remains stable.
Workflow
- Set N8N_WEBHOOK_URL (or WEBHOOK_URL for older n8n) to https://n8n.example.com/ in the Docker Compose environment and recreate the container.
- Configure the reverse proxy to forward WebSocket upgrades: add proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; and preserve the original Host header.
- Set N8N_PROXY_HOPS=1 so n8n trusts the X-Forwarded-* headers from the proxy.
- Verify that webhook URLs in the editor start with the public domain and that the "Connection lost" badge disappears.
Evidence
Set N8N_WEBHOOK_URL=https://n8n.example.com/ (or WEBHOOK_URL before n8n 2.30.0) and recreate the container with docker compose up -d.
The proxy has to pass WebSocket upgrades (Upgrade and Connection headers over HTTP/1.1) and keep the original Host.
Set N8N_PROXY_HOPS=1 for one proxy, so n8n trusts the X-Forwarded-* headers.
Webhook URLs now read https://n8n.example.com/webhook/... with no port.
- Record date: 2026-10-18T09:41:01.650Z