"Connection lost" & "Invalid origin" error after updating to v2.x (Docker + CyberPanel)

1. Describe the problem/error/question

Hi everyone,

I need help troubleshooting a persistent “Connection lost” error after upgrading my self-hosted n8n instance from v1.78 to the latest v2.6.3 via Docker Compose. My server is managed via CyberPanel (using OpenLiteSpeed/Nginx as a reverse proxy).

The Issue:

Since the update, I constantly see the red banner at the top of the editor:

“Connection lost: You have a connection issue or the server is down. n8n should reconnect automatically once the issue is resolved.”

Even though the UI loads, the connection is unstable.

Troubleshooting attempts:

I have tried the following configurations in my docker-compose.yml, but the issue persists:

  1. Forced N8N_PUSH_BACKEND=server-sent-events to avoid WebSocket issues with CyberPanel.

  2. Set N8N_PROXY_HOPS=1 to handle the reverse proxy headers.

Root Cause Analysis:

Looking at the logs, it appears that CyberPanel (OpenLiteSpeed) is stripping the Origin header before passing the request to n8n. Because n8n v2 seems to have stricter security checks than v1, it rejects these “originless” requests.

I am looking for a way to either:

  1. Bypass this strict origin check in n8n v2 (is there an env variable for this?).

  2. Or confirmation if this is a known incompatibility with CyberPanel’s default proxy configuration.

2. What is the error message (if any)?

Browser UI:

Connection lost: You have a connection issue or the server is down. n8n should reconnect automatically once the issue is resolved.

Docker Logs (docker logs n8n -f):

The logs repeatedly show an “Invalid origin” error with undefined values:

Origin header does NOT match the expected origin. (Origin: "undefined" -> "N/A", Expected: "undefined" -> "undefined", Protocol: "undefined")
ResponseError: Invalid origin!
    at Push.handleRequest (/usr/local/lib/node_modules/n8n/src/push/index.ts:143:10)
    at /usr/local/lib/node_modules/n8n/src/push/index.ts:99:10


I also see validation warnings:

ValidationError: The 'X-Forwarded-For' header is set but the Express 'trust proxy' setting is false (default).

3. Information on your n8n setup

  1. n8n version: 2.6.3
  2. Database (default: SQLite): SQLite
  3. n8n EXECUTIONS_PROCESS setting (default: own, main): default
  4. Running n8n via (Docker, npm, n8n cloud, desktop app): Docker Compose (Self-hosted on CyberPanel/Ubuntu)
  5. Operating system: Ubuntu Linux

Hi @Advaisser

Welcome to the n8n community :tada: !!

I’m not familiar with and did not find in the documentation any environment variable in n8n v2 to ignore or relax the Origin check.
From what I’ve seen, it’s a known proxy configuration issue, not an n8n issue.

validations

Check the headers that arrive in the container

proxy_set_header Host $host;
proxy_set_header Origin $scheme://$host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Host $host;

And Docker

environment:

  • N8N_HOST=seu-dominio.com
  • N8N_PROTOCOL=https
  • N8N_PORT=5678
  • N8N_PROXY_HOPS=1
  • N8N_PUSH_BACKEND=server-sent-events

Then, reload the editor; we hope the banner disappears and the connections become stable.