After upgrading to n8n 1.88, the editor loads and then says Connection lost. The browser console shows [WebSocketClient] Connection lost, code=1008. That is the push connection (/rest/push) being refused, and the reason is in n8n's log, not the browser: Invalid origin!, or on later versions Origin header does NOT match the expected origin.
n8n issue #14653 collected 80 comments between April and December 2025 on exactly this. It was closed as not planned on 15 August 2025, and people kept posting fixes after that (one on 1.114.4 in October). Reading it end to end, there is not one fix. There are seven different ways the same check failed, six with a fix that worked for the person who posted it. Here they are, so you can find yours first.
What the check compares
The push endpoint (packages/cli/src/push/index.ts) compares the browser's Origin header with the host n8n expects for the request, and closes the socket with 1008 when they differ. What "expected" means changed between the versions in this thread, so check yours:
-
1.88.0:
Originmust equalhttp://orhttps://plus theHostheader. -
1.98.1: n8n strips the scheme from
Originand compares what is left with theX-Forwarded-Hostheader when it is a string, and withHostotherwise. -
1.114.4: the check moved to
origin-validator.ts. It reads the RFC 7239Forwardedheader first, thenX-Forwarded-Host, thenHost, and drops default ports before comparing.
(Read at the tags n8n@1.88.0, n8n@1.98.1 and n8n@1.114.4 in the n8n repository.) A reverse proxy sits in between and can change both sides: it can rewrite Host, add or rewrite X-Forwarded-Host, and rewrite or drop Origin. Every failure mode below is a proxy handing n8n a different value than the browser sent.
1. nginx: set Host and Origin on the push route, with the port the browser used
An early answer in the thread (adshrc, 16 April) was to stop using $host and set both headers explicitly:
proxy_set_header Host n8n.example.com;
proxy_set_header Origin https://n8n.example.com;
Later in the thread two people posted configs that build the values from nginx variables instead, on the push location only, and said they worked (Ethonwu, 27 June, posted for Nginx Proxy Manager; SKisContent on 1.104.2, 2 August). Trimmed to the lines both posted:
location /rest/push {
proxy_pass http://localhost:5678;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header Origin $scheme://$http_host;
}
The difference that matters is $host versus $http_host: in nginx $host is the host name without a port, while $http_host is the Host request header as the browser sent it, port included. One caveat from the source above: on 1.98.1 and later, if your proxy also sends X-Forwarded-Host, that header, not Host, is the value Origin is compared with.
2. nginx: the same fix stops working, because it is the port
One user (easyservices) fixed 1.88.0 with the port in both headers: Host n8n.<myhost>.fr:<myport> and Origin https://n8n.<myhost>.fr:<myport>. After upgrading to 1.95.2 it broke again, and the fix was the opposite for Origin:
proxy_set_header Origin https://<my_public_host>; # port number removed
plus N8N_PROXY_HOPS=1 and N8N_PUSH_BACKEND=websocket on the n8n side.
The next day (3 June) the same author took it back: "Force the Origin header as I did above is finally a really bad idea, for security reasons." Their replacement, working on 1.95.3, sets no Origin at all and gives Host and X-Forwarded-Host the host and port the client sees:
proxy_set_header Host <visible to client host>:<visible to client port>;
proxy_set_header X-Forwarded-Host <visible to client host>:<visible to client port>;
proxy_set_header X-Forwarded-Port <visible to client port>;
Another commenter (actuallymentor, 2 July) inspected the logs and saw that n8n expects Origin to include the port, at least with TLS, and posted proxy_set_header Origin $host:$server_port; (no scheme). In the same comment they call that "NOT a good thing": the Origin header should not enforce ports, it is browser-controlled, and they suggest that is why it breaks on Chrome but not Firefox. The 15 August closing comment from an n8n team member says that with an Origin header the port is optional (http defaults to 80, https to 443), and that with a non-standard port the port would be needed as well.
3. Nginx Proxy Manager: you may need no custom config at all
rialco (30 June, NPM 2.12.3, n8n 1.100.1) says you do not need any of the custom config in NPM, only the Websockets Support switch on the proxy host. The maintainer's closing comment says that with Nginx Proxy Manager there is no need for custom options. Check that box before you paste any of the above.
4. IIS with ARR: the Host header you set is not the one n8n gets
fernandobnog's IIS setup failed with fixed headers on every version above 1.86.0, until a chain of IIS, then nginx, then n8n worked. EJocys (IIS only, 1.88, downgraded to 1.86.1 first) then found why the web.config header override did nothing: Application Request Routing ignored <set name="HTTP_HOST" ...> and sent the host from the <action> URL, so n8n received Host: 127.0.0.1:5678 even with preserveHostHeader="true" in the site's web.config. What fixed it, in EJocys's words: set preserveHostHeader to True at the server level (IIS Manager, server node, Application Request Routing Cache, Configuration Editor, section system.webServer/proxy). One more detail from the same comment: N8N_LOG_LEVEL=debug did not say why the origin was invalid.
5. CloudFront: the Origin header never arrives
samadwar (17 April; Docker on Fargate behind an ALB and CloudFront) got Connection lost and Invalid origin! only through CloudFront. They found it by pointing the proxy at an echo server and looking at the headers n8n would see, and fixed it in the CloudFront settings; their guess, hedged in the comment, is the cache policy that allows the Origin header through.
6. Other proxies in front: fixed headers did not help
kamil256 (Ocelot) and ppisko (a plain nginx config on 1.88.0) both report that setting fixed Host and Origin made no difference, and RyonMB reports that 1.89 returns a 500 with Invalid origin! instead of the 1008. This is the part of the thread with no answer: three reporters, no recorded fix.
7. Apache: the expected origin is computed twice
CometDog (17 June, n8n 1.98.1, Apache to Docker) had a working WebSocket upgrade and still got the disconnect. Their log line:
Origin header does NOT match the expected origin. (Origin: "myorigin.com", Expected: "myorigin.com, myorigin.com")
n8n expected the origin as a comma-separated pair, and setting N8N_ALLOWED_ORIGINS to one value, or a wildcard, changed nothing. What they did, in their words "duplicated on purpose to satisfy n8n":
<LocationMatch "^/rest/push">
RequestHeader set Origin "myorigin.com, myorigin.com"
RequestHeader set Host "myorigin.com"
</LocationMatch>
In October another user on 1.114.4 (Apache on Windows, N8N_PROXY_HOPS=1, N8N_PROTOCOL=https, WEBHOOK_URL and N8N_EDITOR_BASE_URL set) posted a log with the same shape: Expected: "mydomain.com, mydomain.com". No one in the thread explains why the expected value is doubled.
Which one are you
Read the line in the n8n log, not the red box: on 1.98.1 and 1.114.4, the two versions whose source I read, it prints both sides of the comparison, and a headers object with host, origin and x-forwarded-host. If Origin and Expected differ only by a port, start with failures 1 and 2. Look at x-forwarded-host before you edit Host: on those versions it is what the origin is compared with when it is present. If your proxy is IIS, failure 4. If the expected value repeats itself, you are the case in failure 7.
Where this comes from
Everything above is from one GitHub thread, linked to the comment authors' own words. It is the lead source of the theme "Editor websocket fails behind nginx reverse proxy after upgrade" (3 source threads) on n8n's page on Friction, which groups 39 recent reports from 80 public threads, each linked to its source. Free with an account: watch n8n and get an email when a new report is added. What is stored and how to dispute a report: the data page.
The one detail the thread leaves open: both doubled-origin logs (1.98.1 on Apache in June, 1.114.4 on Apache in October) show Expected: "<host>, <host>". In the source above, that string is the whole X-Forwarded-Host value on 1.98.1, and the raw expected host on 1.114.4, so the value reached n8n doubled. In the October config the author sets X-Forwarded-Host by hand in the vhost and has ProxyPreserveHost On. The checkable question: in your n8n log, does x-forwarded-host show the host once or twice, and what sits in front of n8n? If you run it behind Apache, nginx or Caddy, reply with your version, what is in front, and whether the log prints it once: that is what would show where the second copy comes from.
From Friction, by Grain64.
Top comments (0)