i updated n8n to 1.5 im getting connection lost @ Jan Oberhauser
Hey @Sale.Favourite_fab,
I suspect this could be down to the websocket change, Have you updated your reverse proxy (if you are using one) to support web sockets?
Not sure how to add wss in the config of nginx. but in the GUI there is a slider to enable it. So it does seem to be something specific you have to set to enable it.
Hi @Sale.Favourite_fab, in addition to what @BramKn shared above for Nginx Proxy Manager, can you try updating the proxy_set_header Connection
line when using a hand-crafted server block as suggested by @cuman over here? This seems to have done the job
You could also switch back to server-sent events (this is the technology used by n8n before v1) if you prefer. To do so, youād need to set the N8N_PUSH_BACKEND=sse
environment variable and restart n8n to pick up the change.
I was having the same problem and enabling Websockets Support in the Nginx GUI fixed it for me.
I had the same issue after upgrading to 1.0.5
The sse
fix proposed on Permanent "Connection lost" error for n8n next did the trick for me, as I am running Docker with Apacheās reverse proxy.
@MutedJam do you foresee a future issue with not using the default websocket
setting from now on?
PS: Looking for āConnection Lostā on this forum top search field only shows results older than 1 year, unless you click āMoreā. So I was about to create yet another duplicate post for this question ā¦
Hey @jb8n,
v1 made the change from SSE to Websockets so I donāt expect this to change any time soon.
To make it clear. WebSockets will be the only option in the future. So switching over is required at some point in the future anyway.
Hello!
I stumbled upon the same issue after updating to version 1.0.5.
Iāve installed n8n with npm and am using NGINX reverse proxy.
Adding the following to my n8nās sites-enabled config fixed the websocket connection issue for me:
# Main location block with added Websockets support
location / {
proxy_pass http://nn_backend;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Frame-Options SAMEORIGIN;
proxy_buffers 256 16k;
proxy_buffer_size 16k;
client_max_body_size 50m;
client_body_buffer_size 1m;
proxy_read_timeout 600s;
proxy_buffering off;
proxy_cache off;
}
# Webhook location block with added Websockets support
location ~ ^/(webhook|webhook-test) {
proxy_set_header Connection '';
chunked_transfer_encoding off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Frame-Options SAMEORIGIN;
proxy_buffering off;
proxy_cache off;
proxy_pass http://nn_backend;
}
Since you were not sure how to add websocket support in the config of nginx, I hope this would help other people using n8n 1.x.x without issues.
Cheers!
Hi there,
I have the same issue but I use Apache2ā¦ Iāve enabled the mod_proxy_wstunnel but I canāt make it work. I guess I donāt have the right configuration.
Has anyone here with a similar environment succeeded?
Thank you.
Kind regards,
I have a separate post about it but cant get it figured out either.
Hey @Nicolas_Esteves,
Have you tried adding RewriteCond %(HTTP:Upgrade) websocket [NC]
to your proxy settings?
Hi there,
Here is what I have:
RewriteCond ${HTTP:Upgrade} websocket [NC]
RewriteCond ${HTTP:Connection} upgrade [NC]
RewriteRule .* "wss:/localhost:5680/$1" [P,L]
ProxyPass /wss/ wss://localhost:5680/
ProxyPassReverse /wss/ wss://localhost:5680/
ProxyPass / http://localhost:5680/
ProxyPassReverse / http://localhost:5680/
Clearly, Iām ashamed to say that but, I have no idea what Iām doing. Iām not a newbie with Apache2 but this is the first time Iām trying to use a websocket.
Any idea? Thank you.
PS: Iāve tried many things, previous sample is just my last attempt.
Hi @jan,
I think Iām going to use the āsseā fix for the moment as Iām really stuck. Do you think that would be possible to make sure a valid example for Apache is available before making websockets the only available option?
Thank you.
Kind regards,
Hey @Nicolas_Esteves,
It is tricky really, We could document it for Apache but then we would also have to document it for all of the other reverse proxies which would take time.
Did you try without the options below in your config file?
RewriteRule .* "wss:/localhost:5680/$1" [P,L]
ProxyPass /wss/ wss://localhost:5680/
ProxyPassReverse /wss/ wss://localhost:5680/
I will see if I can free up some time to work out what is actually needed for Apache as it is not really something I use.
Alright so for anyone that needs it I have just spent a bit of time learning about Apache2 as a reverse proxy.
To get n8n up and running with Websockets in 1.0 below is an example config file that works when used with n8n in a container. This example is for HTTP so if you were using HTTPS you would need to make those changes.
<VirtualHost *:80>
ServerName n8n.yourdomain.tld
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://172.17.0.1:5678/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://172.17.0.1:5678/$1 [P,L]
ProxyPassReverse / http://n8n.yourdomain.tld
</VirtualHost>
This will need proxy, proxy_http, proxy_wstunnel and rewrite to work but as of right now on a clean Digital Ocean droplet using n8n 1.1.1 this works.
Thanks @Jon, I was close but couldnāt have made it work without your help, or at least not without losing a few extra hours! So thank you very much!
Hereās the final solution, if it helps anyone else:
<VirtualHost *:80>
# HTTP -> HTTPS
ServerName n8n.domain.com
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>
<VirtualHost *:443>
ServerName n8n.domain.com
SSLEngine On
SSLProxyEngine On
ProxyRequests Off
ProxyPreserveHost On
SSLCertificateFile /etc/apache2/certs/2023_wildcard.domain.crt
SSLCertificateKeyFile /etc/apache2/certs/2023_wildcard.domain.key
SSLCertificateChainFile /etc/apache2/certs/2023_wildcard.domain_inter.crt
TimeOut 600
KeepAliveTimeout 600
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
<Proxy *>
Require all granted
</Proxy>
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://localhost:5678/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://localhost:5678/$1 [P,L]
ProxyPassReverse / http://n8n.domain.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Have a nice day!
Kind regards,
Thank you @Nicolas_Esteves for sharing this.
After trying a long time to fix exactly the same issue, i came to your post and it seems to work
But sporadically, I face problems that I canāt access to n8n at all with a browser error message:
Bad Gateway
The proxy server received an invalid response from an upstream server.
or
Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request
Reason: Error reading from remote server
After refreshing, it will work most of the timeā¦
Could it be that I have still some issues with my apache2 reverse proxy settings?
Does anybody knows how to fix this issue?
Thank you
Edit: It even fails sometimes if I load it locally over localhost:5678