✅ solved: "Connection Lost" in workflow editor

I had this “Connection Lost” in workflow editor for more than a week. tried everything found on the forums. Nothing worked. Then I reinstalled the n8n ( on GCP using Docker ), still error wasn’t fixed. So finally I decided give all my configurations and errors to chatGPT and ask to help. Finally it helped me to fix it. The issue was in the WebSockets.

nginx config : before fix

server {
    server_name automation.webloomlabs.net;
    location / {
        proxy_pass http://localhost:5678;
        proxy_http_version 1.1;
        chunked_transfer_encoding off;
        proxy_buffering off;
        proxy_cache off;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/automation.webloomlabs.net/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/automation.webloomlabs.net/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
    if ($host = automation.webloomlabs.net) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;
    server_name automation.webloomlabs.net;
    return 404; # managed by Certbot


}

nginx config : after fix

server {
    server_name automation.webloomlabs.net;

    location / {
        proxy_pass http://localhost:5678;
        proxy_http_version 1.1;
        chunked_transfer_encoding off;
        proxy_buffering off;
        proxy_cache off;

        # WebSocket support
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        # Required headers
        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;
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/automation.webloomlabs.net/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/automation.webloomlabs.net/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}

server {
    if ($host = automation.webloomlabs.net) {
        return 301 https://$host$request_uri;
    }

    listen 80;
    server_name automation.webloomlabs.net;
    return 404;
}

2 Likes

Excelente bro, muchas gracias. No hay prácticamente nada de ayuda en español y encontrarte llevó un tiempo… Lo que hice fue actualizar a la versión más actual de n8n (latest version), Para eso me tocó configurar la autenticación de dos pasos de GCP. Luego hagan la configuración de Nginx (algunos la pueden tener en Apache. Igual, lo explica con ese modo). Para ello, usé Gemini y fue paso a paso hasta lograrlo.

Please be polite and post in English on this forum.

GREAT bro, thank you so much. There’s practically no help in Spanish, and finding you took a while… What I did was update to the latest version of n8n. For that, I had to configure GCP’s two-step authentication. Then, do the Nginx configuration (some might have it in Apache. It explains it that way too). For this, I used Gemini, and it was step-by-step until I got it.

Unfortunately, it is (still) not working for me. Please kindly look at my configuration:

server {
    listen 80;
    server_name my_server_dns_address;

    location / {
        proxy_pass http://<n8n_server_IP>:5678/;
      
        proxy_set_header Host $host;
        proxy_set_header Origin https://my_server_dns_address;
        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 Accept-Encoding "";
        proxy_buffering off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        gzip off; # Disable compression on the reverse proxy
    }

    location /rest/push {
        proxy_pass https://my_server_dns_address:5678;
       
        proxy_set_header Host $host;
      
        proxy_set_header Origin https://my_server_dns_address:5678;
        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_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_buffering off;
        proxy_cache off;
        chunked_transfer_encoding off;

        proxy_read_timeout 3600s;
        proxy_send_timeout 3600s;
        proxy_connect_timeout 3600s;
    }
}

Maybe you’d find something to fix, thanks!

Out of curiosity. What Google GCP MFA / two-step auth has to do with this problem?

Good question. The issue was that there was no connection between n8n and my server, in this case, Google Cloud Platform. I saw several tutorials that suggested it was due to an n8n update, so I updated it, but the problem persisted. Then I went to GCP, and when I tried to log in, it wouldn’t let me until I configured 2-Step Verification. I set it up, but the problem remained… so I re-entered my Google credentials in the nodes, and it still didn’t work. Finally, using Gemini throughout the process, I did the Nginx configuration, and it worked.

I’ve spent considerable time on this topic, testing various configuration options and switching from “sse” to “websockets,” but the issue kept recurring. To isolate the problem, I conducted an experiment where I bypassed nginx and connected directly to the latest version of n8n (1.93.0) using the WebSocket option. This worked successfully on a new dedicated port (other than 5678). However, when I reintroduced nginx, the problem resurfaced. Despite carefully checking all configuration lines, nothing seemed to resolve it.
I then created a fresh nginx configuration from scratch using the new experimental port, but it didn’t work initially. A standard nginx service restart didn’t help either. However, after restarting the entire VM on GCP (which forced nginx to start fresh) the issue was finally resolved. I’m sharing this in case it helps others facing a similar problem.

I upgraded to 1.94.0 with Docker and also now face the “Connection Lost” in workflow editors :frowning:

I had that issue in the past and already have the sse parameter in the docker compose. The upgrade to 1.94.0 is the one that broke it for me (I hadn’t upgraded in 2 months).

As suggested in other posts, I tried:

  • editing the value for N8N_PUSH_BACKEND to websocket and back to sse. It didn’t work. I had no change to my apache config in a while, it’s something that changed with N8N.
  • moving from sse to websocket and adding a ProxyPass /ws/ ws://localhost:5678/ws/ line in my apache conf file. It didn’t work, I still have n8n running but “Connection Lost” on all workflow editors.

I am with Apache and many helpful comments are about nginx. Has anyone solved this issue with Apache in the recent weeks?

EDIT: It seems solved it thanks to Jon’s answer on N8N behind Apache Reverse Proxy - #4 by Jon

SOLUTION (that worked for me, on Ubunbu24/Docker/Apache):

  • Replace sse by websocket in the docker-compose variable N8N_PUSH_BACKEND
  • Edit the Apache conf file to add a websocket rewrite rule:
   	RewriteEngine On
   	RewriteCond %{HTTP:Upgrade} =websocket [NC]
   	RewriteRule /(.*) ws://0.0.0.0:5678/$1 [P,L]

Thank you very much ! I just have to add the websocket and now it’s working !