UI Connection Lost - Server-Sent Events


I’m getting this error yet I believe there is connection since the app works just fine when I interact with the UI, change or save something in a workflow.


This is happened after I configured a reverse proxy in front of n8n. Here is the setup:

  • n8n.example.com points to nginx server.
  • NGINX works as reverse proxy on nginx server. listen n8n.example.com 443 and redirects N8NServer:5678
  • n8n container works on N8NServer mapped to 5678:5678

n8n container deployed via docker-composed using below env. variables and using sqllite

  - N8N_PROTOCOL=https
  - N8N_HOST=n8n.example.com
  - VUE_APP_URL_BASE_API=https://n8n.example.com/
  - WEBHOOK_TUNNEL_URL=https://n8n.example.com/
1 Like

Guess the problem is that the reverse proxy is not configured correctly to work with Server-Sent Events. For that reason do you see this error message. You should find the solution here:

Hello guys…
I’m on this issue “Lost Connection”… but my server is Apache… I’ve make a research and saw it’s very different from nginx configs and didn’t find anything here at community…
Do you have some hint?
Sometimes I get “404 page not found” too… and have to restart n8n…

@simeia sorry have even less knowledge about Apache than Nginx. I can only advise you to check the Nginx settings and then look online for settings in Apache which do the same.

Or you can search generally on Google for “server sent events” and Apache to find a possible configuration.

If none of it works for you I can sadly simply only advice you to use the default configuration with Nginx which can be found in the documentation.

Thanks @jan I’m just doing this…

I have exactly the same setup. Using Caddy v1, the following solution worked:

n8n.example.co.uk {
    proxy / localhost:5678 {

However, I’m migrating to Caddy v2 and can’t seem to get the same to work. My Caddyfile v2 equivalent is:

n8n.example.co.uk {
    reverse_proxy http://localhost:5678

This should work but it doesn’t and for the life of me I cannot work out why

I figured it out how to make it work!

To handle server push event with Caddy (v2) you need to enable flush_interval. My final caddy config looks like this:

n8n.example.com {
  reverse_proxy {
    flush_interval 10

Here’s my environments:

      - N8N_PORT=5678
      - VUE_APP_URL_BASE_API=https://n8n.example.com
      - WEBHOOK_TUNNEL_URL=https://n8n.example.com```

Thanks a lot @lokahi for sharing this!

This is my super basic nginx proxy setup

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    # SSL configuration
    listen 443 ssl default_server;
    listen [::]:443 ssl default_server;

    ssl_certificate /etc/ssl/cert-with-chain.crt;
    ssl_certificate_key     /etc/ssl/server.key;
    server_name _;

    location / {

        # server sent events
        proxy_set_header Connection '';
        proxy_http_version 1.1;
        chunked_transfer_encoding off;
        proxy_buffering off;

For those wondering how to solve it behind an Ambassador Edge Stack (Kubernetes), just add the timeout_ms spec:

apiVersion: getambassador.io/v2
kind: Mapping
  name: n8n-mapping
  namespace: n8n
  timeout_ms: 0
  prefix: /
  host: <domain>
  service: <service>:5678

Hey @Frederik,

Welcome to the community :sparkling_heart:

Thank you for sharing your solution!

I have the same problem. I use docker and nginx

docker-compose file

version: '3.1'

    image: docker.n8n.io/n8nio/n8n
    restart: always
      - ""
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=urs
      - N8N_BASIC_AUTH_PASSWORD=pas277
      - N8N_HOST=n8n.cybershu.eu
      - N8N_PORT=5678
      - N8N_PROTOCOL=http
      - WEBHOOK_URL=https://n8n.cybershu.eu/
      - VUE_APP_URL_BASE_API=https://n8n.cybershu.eu/
      - /var/run/docker.sock:/var/run/docker.sock
      - ./n8n:/root/.n8n

nginx configuration file:

server {
    server_name n8n.cybershu.eu;

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

	    #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_http_version 1.1;
        #proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection '';

    listen 443 ssl; # managed by Certbot
    listen [::]:443 ssl;
    ssl_certificate /etc/letsencrypt/live/n8n.cybershu.eu/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/n8n.cybershu.eu/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 = n8n.cybershu.eu) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    listen 80;
    server_name n8n.cybershu.eu;
    return 404; # managed by Certbot

Hi @michmzr, welcome to the community!

Your nginx config looks good to me, I have actually used a similar one in the past without problems.

So I am not sure this is actually a problem with the SSE approach of passing data from the server to the frontend. You can, however, easily rule this out as a possible cause by switching to websockets.

If that’s not it and seeing this thread is several years old, perhaps you can open a new thread specifying exactly what you’re doing when running into the “connection lost” problem?

Thank you @MutedJam for response.
I have the same problem when I switched. I created a separate thread to mitigate problem Websockets and SSE connection lost

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.