# 401 websocket error

**URL:** <https://community.n8n.io/t/401-websocket-error/54629>\
**Category:** Questions\
**Created:** [September 20, 2024, 1:16am UTC](https://community.n8n.io/t/401-websocket-error/54629 "2024-09-20T01:16:15Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mehdi\_med](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mehdi_med/32/44865_2.png) [@mehdi\_med](https://community.n8n.io/u/mehdi_med)\
**Post date:** [September 20, 2024, 1:16am UTC](https://community.n8n.io/t/401-websocket-error/54629/1 "2024-09-20T01:16:15Z")

</div>

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

```auto
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

```auto
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

---

<div class="post-metadata">

**Author:** ![n8n](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/n8n/32/196425_2.png) [@n8n](https://community.n8n.io/u/n8n)\
**Post date:** [September 20, 2024, 1:16am UTC](https://community.n8n.io/t/401-websocket-error/54629/2 "2024-09-20T01:16:20Z")

</div>

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:**

---

<div class="post-metadata">

**Author:** ![mehdi\_med](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mehdi_med/32/44865_2.png) [@mehdi\_med](https://community.n8n.io/u/mehdi_med)\
**Post date:** [September 20, 2024, 3:27am UTC](https://community.n8n.io/t/401-websocket-error/54629/3 "2024-09-20T03:27:03Z")

</div>

> [@n8n](#):
>
> 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

---

<div class="post-metadata">

**Author:** ![netroy](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/netroy/32/22154_2.png) [@netroy](https://community.n8n.io/u/netroy)\
**Post date:** [September 20, 2024, 5:54am UTC](https://community.n8n.io/t/401-websocket-error/54629/4 "2024-09-20T05:54:53Z")

</div>

Please try updating the nginx conf to

```auto
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;
    }
} 

```

---

<div class="post-metadata">

**Author:** ![mehdi\_med](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mehdi_med/32/44865_2.png) [@mehdi\_med](https://community.n8n.io/u/mehdi_med)\
**Post date:** [September 20, 2024, 11:01am UTC](https://community.n8n.io/t/401-websocket-error/54629/5 "2024-09-20T11:01:05Z")

</div>

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:

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

```

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

Thanks again Netroy 🙂

---

<div class="post-metadata">

**Author:** ![netroy](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/netroy/32/22154_2.png) [@netroy](https://community.n8n.io/u/netroy)\
**Post date:** [September 20, 2024, 12:21pm UTC](https://community.n8n.io/t/401-websocket-error/54629/6 "2024-09-20T12:21:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mehdi\_med](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mehdi_med/32/44865_2.png) [@mehdi\_med](https://community.n8n.io/u/mehdi_med)\
**Post date:** [September 20, 2024, 2:33pm UTC](https://community.n8n.io/t/401-websocket-error/54629/7 "2024-09-20T14:33:11Z")

</div>

> [@netroy](#):
>
> `proxy_set_header Cookie $http_cookie;`

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…

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [December 19, 2024, 2:33pm UTC](https://community.n8n.io/t/401-websocket-error/54629/8 "2024-12-19T14:33:39Z")

</div>

Closed on December 19, 2024, 2:33pm UTC

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