Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Fix n8n 'Connection Lost' and Webhook URLs Behind a Proxy

说明与用途

将 n8n 放在反向代理后,Webhook URL 显示 localhost 和内部端口,编辑器持续显示 "Connection lost"。通过设置 N8N_WEBHOOK_URL、在代理中启用 WebSocket 并设置 N8N_PROXY_HOPS 可以解决此问题。

问题

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.

结果

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.

工作流

  • 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.

证据

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.

来源

  • 记录日期: 2026-10-18T09:41:01.650Z