401 websocket error

Hello,

I need you help please.

I don’t understand, I have a 401 error related to websockets
Browsing the forum, I see that there are several different ones that return a 401

I understand that this error is related to websockets, but I don’t understand what’s happening and why I have this error and why I can’t get rid of it, it prevents me from creating a workflow correctly

I have version 1.59.3 of n8n and nginx 1.27.1

Here is my nginx config file

version: '3'

services:
  n8n:
    image: n8nio/n8n
    restart: always
    environment:
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=MyUser
      - N8N_BASIC_AUTH_PASSWORD=MyPassword
      - N8N_HOST=n8n.mydomain.com
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_URL=https://n8n.feedbypixels.be
      - GENERIC_TIMEZONE=Europe/Brussels
      - N8N_ALLOW_PROXY_RETRIES=true
    ports:
      - "5678:5678"
    volumes:
      - ./n8n:/home/node/.n8n

Here is my Docker compose

server {
    listen 80;
    server_name n8n.feedbypixels.be;

    return 301 https://$host$request_uri;

    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 X-Forwarded-Proto $scheme;
        proxy_buffering off;
        client_max_body_size 100M;
    }
}

If someone could tell me why and what I’m doing wrong or not doing to always have this 401 error please, I really thank you for your help please

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Missing information
n8n version: 1.59.3
Database: SqlLite
n8n Parameters EXECUTIONS_PROCESS (default: own, main):Default
Run n8n via : Docker
Operating system: Debian

Please try updating the nginx conf to

server {
    listen 80;
    server_name n8n.feedbypixels.be;

    return 301 https://$host$request_uri;

    location / {
        proxy_pass http://127.0.0.1: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 X-Forwarded-Proto $scheme;
        proxy_buffering off;
        client_max_body_size 100M;

        proxy_set_header Connection 'upgrade';
        proxy_set_header Upgrade $http_upgrade;
        proxy_connect_timeout 300s;
        proxy_read_timeout 300s;
        proxy_send_timeout 300s;
    }
} 

Thank you for your reply @Netroy

I’ve just updated the Nginx configuration and restarted the service on your advice but I still get the same error:

GET https://n8n.feedbypixels.be/rest/login 401 (Unauthorized)

It’s quite penalizing, impossible to create workflows because of it…

Thanks again Netroy :slight_smile:

can you please try adding proxy_set_header Cookie $http_cookie; to make sure that the Cookie header is correctly forwarded to n8n?

Thanks Netroy

I also just added:

“proxy_set_header Cookie $http_cookie;”

I still get this 401 error, I really think I’ve tested everything…

Isn’t there a previous version that uses a different authentication processing mode? I think it’s from a certain version onwards that the processing is done via websocket, if I’m not mistaken…

I absolutely must get this to work, even if I have to use a previous version…

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