Connectivity Issues with n8n Workflows

Describe the problem/error/question

What is the error message (if any)?

Connectivity Issues with n8n Workflows

I’m having trouble accessing any workflow I’ve created. As soon as I access it, a notification appears in the top right corner saying: “Connection lost.”

I use n8n on an on-premise machine, running docker-compose.

Please share your workflow

My docker-compose.yml

Error screenshot

Information on your n8n setup

  • n8n version: Latest
  • Database (default: SQLite): MySQL 5.7
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Ubuntu

Hey @GuilhermeTrivilin,

My first thought is your reverse proxy is not correctly configured to handle websockets, Can you try accessing your n8n instance using the IP / bypassing the reverse proxy to see if the issue is still there?

When accessing directly via the machine’s IP, it works correctly. Additionally, when accessing both through the machine’s IP and my domain, the list of workflows returns different items. What could be the cause?

An important note is that we use Cloudflare, and it supports WebSocket by default.

Hey @GuilhermeTrivilin,

Returning differnet workflows is odd it should be the same, It could be that the cloudflare caching is causing an issue. Are you using a Cloudflare tunnel or just Cloudflare for DNS?

@Jon , i’m using cloudflare for DNS only

@Jon, I believe it has to do with my nginx configuration. I don’t have much expertise in this regard, can you help me? Here’s my nginx config:



server {
    listen 80;
    server_name n8n-xxxx.kiskadi.com;

    location / {
        return 301 https://$host$request_uri;
    }
}
server {
    listen 443 ssl;
    server_name n8n-xxxx.kiskadi.com;

    ssl_certificate /etc/letsencrypt/live/n8n-xxxx.kiskadi.com/fullchain.pem; 
    ssl_certificate_key /etc/letsencrypt/live/n8n-xxxx.kiskadi.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf; 
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

    location / {
        proxy_pass http://localhost:5678;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

Hey @GuilhermeTrivilin,

nginx would be the reverse proxy I asked about previously, So it looks like you don’t have the options set that nginx needs for websockets to function properly. Try something like the below, I would run it past your server admin first to verify but it should be close to what you need.

server {
    listen 80;
    server_name n8n-xxxx.kiskadi.com;

    location / {
        return 301 https://$host$request_uri;
    }
}
server {
    listen 443 ssl;
    server_name n8n-xxxx.kiskadi.com;

    ssl_certificate /etc/letsencrypt/live/n8n-xxxx.kiskadi.com/fullchain.pem; 
    ssl_certificate_key /etc/letsencrypt/live/n8n-xxxx.kiskadi.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf; 
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

    location / {
        proxy_pass http://localhost:5678;
        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 Connection 'Upgrade';
        proxy_set_header Upgrade $http_upgrade;
        proxy_http_version 1.1;
    }
}
1 Like

Thank you so much for the help, @Jon! The configuration you sent me didn’t work, but I disabled some buffering and cache, and it worked (I found this information in another post here in the community).

For anyone facing the same issue, in the end, my nginx looked like this:

server {
    listen 80;
    server_name n8n-xxxx.kiskadi.com;

    location / {
        return 301 https://$host$request_uri;
    }
}
server {
    listen 443 ssl;
    server_name n8n-xxxx.kiskadi.com;

    ssl_certificate /etc/letsencrypt/live/n8n-xxxx.kiskadi.com/fullchain.pem; 
    ssl_certificate_key /etc/letsencrypt/live/n8n-xxxx.kiskadi.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf; 
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

    location / {
        proxy_pass http://localhost:5678;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        # To make the websocket work, add the following lines to your nginx:
        proxy_set_header Connection 'Upgrade';
        proxy_set_header Upgrade $http_upgrade;
        proxy_http_version 1.1;
        proxy_buffering off;
        proxy_cache off;
        chunked_transfer_encoding off;
    }
}
1 Like

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