Connection lost

Thanks a lot @Tephlon!

Here are some other topics @TimoG which talks about the same topic of port 443 being already in use:

I did the setup guide. But we created a dns record before that. So we have one thats active.
But its does not work with the dns record. And thats not the problem. The dns records works fine, but i cant start it.
My docker-compose file is the same as in the guide and my n8n.env looks like this:

n8n.env

Folder where data should be saved

DATA_FOLDER=/var/www/html/n8n/

The top level domain to serve from

DOMAIN_NAME=aundb.io

The subdomain to serve from

SUBDOMAIN=n8n

DOMAIN_NAME and SUBDOMAIN combined decide where n8n will be reachable from

above example would result in: https://n8n.example.com

The user name to use for autentication - IMPORTANT ALWAYS CHANGE!

N8N_BASIC_AUTH_USER=******

The password to use for autentication - IMPORTANT ALWAYS CHANGE!

N8N_BASIC_AUTH_PASSWORD=******

Optional timezone to set which gets used by Cron-Node by default

If not set New York time will be used

GENERIC_TIMEZONE=Europe/Berlin

The email address to use for the SSL certificate creation

[email protected]

But i saw, that the docker-compose version is sadly not compatible with apache on the same server.
But it starts if i stop the apache2 service, but i cant open the interface with the domain. I dont get a secure connection.

Now i installed it on a new server without apache but it says now 4 warnings that variables of the .evn file are not set but they are in the n8n.env.
And the logs dont helping me in any way. It says that the file /home/node/.n8n exists but its definitly not. The folder node dont exists too.

Okey, i found a solution on my own. I though that i must create a .env file with any name, but i had to name it ONLY .env. Now it works.

Ah great to hear that you did figure it out. Because I read your answer and was confused why it would not work. Did somehow think you only wrote n8n.env to describe it and not that you actually named it that way. Sorry should have really caught that and then asked.

Hi all,

I am running into the same issue. I am running n8n dockerized. Using a docker-compose.yml file similar to the one in the setup guide, slightly modified to use the env file directly:

  n8n:
    image: n8nio/n8n:0.68.2-push-debug
    env_file: n8n.env
    container_name: n8n
    restart: always
    ports:
      - 5678:5678
    volumes:
      - ~/.n8n:/root/.n8n
      - /var/run/docker.sock:/var/run/docker.sock
    # Wait 5 seconds to start n8n to make sure that PostgreSQL is ready
    # when n8n tries to connect to it
    command: /bin/sh -c "sleep 5; ./packages/cli/bin/n8n start"

As you can see above, I tried the debugging version mentioned in the thread.

I, however, have nginx instead of traefik (I have other services already running behind nginx)

I can see:

  1. The n8n service actually picks up all the .env variables correctly.
  2. From the debug logs, I can see push requests reaching n8n:
        n8n                    |   method: 'GET',                                                                                                                                                                    
        n8n                    |   url: '/rest/push?sessionId=t26ga6pwy1e',                                                                                                                                          
        n8n                    |   query: { sessionId: 't26ga6pwy1e' }                                                                                                                                               
        n8n                    | }                                                                                                                                                                                   
        n8n                    | *** Is Push-Connect-Request                                                                                                                                                         
        n8n                    | *** Push-Connection gets added
        n8n                    | >> Push.add 1
        n8n                    | >> Push.add 3
        n8n                    | >> Push.disconnect
    

Yet, the Connection lost warning on the top right corner of the dashboard is present and I cannot execute any flow.

Any other idea of what might be happening?

Welcome to the community @jmrf!

If you use nginx it is maybe worth checking out this topic:

Thanks Jan!

Btw, I am Jose, the one you spoke to this morning from MeliorAI. Thanks for the link. Checking!

1 Like

Hi,

Could you please help how to fix this on a containerized environment. Because of connection lost my workflow is not working and i can see this message

“Problem running workflow
There was a problem running the workflow:
No active connection to server. It is maybe down.”

Honestly, it is totally impossible for me to fix this issue as I am unable to reproduce it.

How are you running n8n? Are you 100% sure that you do not have a reverse proxy or anything else (as discussed above) that could cause that problem?

I got the same error this morning and I knew what the issue was. I connected to my company’s network using their proxy servers. Once I did, n8n workflow page said “connection lost” and when I disconnected from the proxy and directly connected to the internet, the error was gone. So, I guess it’s got something to do with the security that’s set by my company. People facing the same issues may test the same in a different PC/network etc to check if that solves the issue.

2 Likes

Hey,

came here to leave a hint for everybody fighting with this problem.
From what I found, the issue is related to the compression. eg. If I remove the Accept-Encoding header from a curl request to /rest/push I get a quite prompt :ok response.

So for my case I’m running n8n in Kubernetes behind Traefik Proxy.
What I had to do was to edit the traefik configmap and disable the compression for both entry points:

[entryPoints]
  [entryPoints.http]
  address = ":80"
  compress = false
  [entryPoints.https]
  address = ":443"
  compress = false

The same should be possible for other reverse Proxies as well.
Hope that helps!

4 Likes

Welcome to the community @anthu!

Thanks a lot for directly helping others with their problem in your very first post. Really great!

2 Likes

Hi!
I have the same problem.
For me, it looks like a nginx config problem (set as a reverse proxy).
I tried to disable buffering and enabled chunked encoding like the documentation showed but nothing works.
I observe one of the following behavior:

  • the push request returns to the browser correctly and a connection error is reported
  • the push request does not return, no connection error is reported but responses from execution of flows are not returned either (the ui is blocked in “Executing workflows”)

If I may, I’d like to suggest an alternative way of polling data from the server:
From what I saw, a lot of proxies/web servers have issues with chunked data and require fine tuning.

It could be more robust to to do this long polling with multiple requests:

  • send the “push” request
  • return the full response even if there is nothing to return from the server after x seconds (or after timeout)
  • sent a new the “push” request as soon as the previous one returns to keep the connection with the server alive
  • and so on…

Of course there is a slight bandwidth loss due to the multiple packet headers but it should not be significant…

Welcome to the community @dcretin!

In my experience does really everything come with advantages but also disadvantages. There are for sure some problems with EventSource, but considering how many people are using n8n worldwide, are they still quite limited and normally a solution can be found. For that reason. am I very hesitant the change something which generally works, just to replace it with a new unkown set of problems, especially if we have currently very limited resources.

But generally agree that this is something we have to improve at some point. Sadly do we have currently already so much to do, with many other very high impact features and issues, that we have to prioritize and for that reason do not know when we can tackle this. Sorry.

I use n8n with the kubernetes helm chart.
You only need to set the following annotation:
ingress.kubernetes.io/compress-enable: “false”

Would be nice if this would be included by default in the helm chart…

It is described here: k8s-ts-ingress/compression.md at master · torchbox/k8s-ts-ingress · GitHub

Anyway, thank you for the hint with compress :slight_smile:
Peter

1 Like

Hi,

For those who are in 2022 or later with this same problem of Connection lost when using nginx, traefik, or another reverse proxy.

The error is caused when the webUI tries to send a request to URI /rest/push?sessionId=12341234 expecting a text/event-stream response and the reverse proxy tries to compress or buffer the response coming from n8n. When trying to compress or buffer the response gets infinitely stuck on the reverse proxy and the webUI never receives a valid connection.

To solve this you need to add flags that disable buffering or compression of responses in the reverse proxy.

Nginx

proxy_pass http://127.0.0.1:5678;
proxy_buffering off;

The important part is just proxy_buffering off; but I kept the proxy_pass for reference of where to insert in the proxy file. You know where to edit as you already have it set up and working.

Kubernetes

metadata:
  annotations:
    ingress.kubernetes.io/compress-enable: "false"

Traefik

[entryPoints]
  [entryPoints.http]
  address = ":80"
  compress = false
  [entryPoints.https]
  address = ":443"
  compress = false
4 Likes

@rafas thank you so much! This helped me resolve issues with our Kubernetes deployment. This should be included in the official documentation.

IMPORTANT NOTE: The recent versions of the Kubernetes Nginx Ingress Controller updated their annotation schema, causing many of the recommended configurations you will find online to not work.

Make sure to use the new annotation format: nginx.ingress.kubernetes.io/proxy-buffering has become nginx.org/proxy-buffering

2 Likes

So I am seeing this as well, only I don’t have any reverse proxies involved. I saw this behaviour on my local docker so it didn’t even leave my machine. Ran great for a day, came in the next day and it’s not working. Moved it off to another docker server, same thing worked great for a day and then no beuno.

Is the log container still a thing? Obviously, I can’t change compression settings but am seriously toying with setting up Traefik just to see if it makes a difference. I come from node-red, so was looking forward to see what it can do with less work :smiley:

Hi @rxc3ntr1c, welcome to the community!

I am very sorry for the trouble. Seeing this is a rather old thread and n8n has changed a lot since this first came up, could you open a new thread with detailed steps on how to reproduce the problem?

Thank you so much!