8gears / n8n-helm-chart

A Kubernetes Helm chart for n8n a Workflow Automation Tool. Easily automate tasks across different services.
https://artifacthub.io/packages/helm/open-8gears/n8n
Apache License 2.0
187 stars 97 forks source link

Init Problem: There was a problem loading init data: Unauthorized #84

Closed samzong closed 5 months ago

samzong commented 6 months ago

As a new user, I ran into this problem, Sorry not to be able to provide more details.

image


ROOT CAUSE

n8n auth cookie has Secure flag set by default now.

if we don't need, disble with env N8N_SECURE_COOKIE:false

https://github.com/n8n-io/n8n/blob/master/packages/cli/BREAKING-CHANGES.md#1320

samzong commented 6 months ago

I got some fixed in n8n community

https://community.n8n.io/t/upgrade-from-1-29-1-to-1-3-1-fails/42153

set env:

N8N_SECURE_COOKIE:false

This is a problem caused by n8n upgrading to new version. I just found a temporary solution, and I don't understand why.

Vad1mo commented 6 months ago

I guess it is your setup, for the record, we have this running with N8N_SECURE_COOKIE: true

samzong commented 6 months ago

I guess it is your setup, for the record, we have this running with N8N_SECURE_COOKIE: true

Ok, I got it, It's just that the upgrade will fail directly. It's very sudden for me. I should pay attention to this part of the change when upgrading.

HWiese1980 commented 5 months ago

So what is the actual solution to this? I'm seeing the same issue on my bare metal K8s. Fresh install from Helm. All default settings, except for the PostgreSQL which is an existing one.

I'm trying to access the webui through a static load balancer IP (MetalLB).

The LB seems to be the reason. I do not get the error when using a port forward to the cluster IP.

Vad1mo commented 5 months ago

User error, you need to have a DB.

sudo -u postgres psql
postgres=# create database mydb;
postgres=# create user myuser with encrypted password 'mypass';
postgres=# grant all privileges on database mydb to myuser;
HWiese1980 commented 5 months ago

Uh, yeah, I do have a DB. It is used, filled, I can totally use N8N over port forward on my localhost. It just doesn't work over the LoadBalancer IP.

Could you please try to reproduce it, maybe? Set up the service so it uses a load balancer and try to access N8N via that IP?

samzong commented 5 months ago

So what is the actual solution to this? I'm seeing the same issue on my bare metal K8s. Fresh install from Helm. All default settings, except for the PostgreSQL which is an existing one.

I'm trying to access the webui through a static load balancer IP (MetalLB).

The LB seems to be the reason. I do not get the error when using a port forward to the cluster IP.

I found more info on the issue that was brought on by the upgrade to v1.32.0.

https://github.com/n8n-io/n8n/blob/master/packages/cli/BREAKING-CHANGES.md#1320

n8n auth cookie has Secure flag set by default now.

If you are running n8n without HTTPS on a domain other than localhost, you need to either setup HTTPS, or you can disable the secure flag by setting the env variable N8N_SECURE_COOKIE to false.

Givemeurcookies commented 4 months ago

Worth mentioning that there was also a bug that was recently fixed that caused the same issue https://github.com/n8n-io/n8n/pull/9212

I have a reverse proxy which terminates TLS prior to reaching the pod and also got the unauthorized messages after logging in. Using the latest image tag (1.39.1) fixed this issue - even when having the N8N_SECURE_COOKIE: true set explicitly.