Password recovery in self hosted instance

So I had to do a few extra steps after identifying the correct path.

These particular CLI commands were missing : usermanagement: update
User:update

I double checked my version with this command to ensure it was an up to date version of n8n:

docker exec -u node -it n8n-docker-caddy-n8n-1 /usr/local/bin/n8n -v

My version is 1.79.3

First I started a shell inside the container using :

docker exec -u node -it n8n-docker-caddy-n8n-1 sh

I needed to reset these credentials via the database with SQLITE (running on Alpine Linux)

Then inside the container, I entered the database with this command :

sqlite3 /home/node/.n8n/database.sqlite

Side note

if you are getting this error:

root@username:~# docker exec -u node - sh

~ $ sqlite3 /home/node/.n8n/database.sqlite

sh: sqlite3: not found

You need to install sqlite3 temporarily using:

(For Alpine Linux)

apk add sqlite

or

(For ubuntu or Debian)

apt update && apt install -y sqlite3

Then ran:

sqlite3 /home/node/.n8n/database.sqlite


Next Once you see ‘sqlite>’ check the users table running this command:

Select id, email FROM user;

Make sure you see your user email

After that (I assume n8n hashes passwords) I generated a hash inside the container using:

node -e “console.log(require(‘bcryptjs’).hashSync(‘CoOl_CaT1’, 10))”

Make sure you note down the generated hash

side note again

You may need to install bcryptjs temporarily before running the hash generator


Go back to your SQlite prompt inside the container and run this command

UPDATE user SET password=‘PASTE_HASH_HERE’ WHERE email=‘user@domain’;

Exit sqlite and restart n8n

.exit
docker restart n8n-docker-caddy-n8n-1

Finally I committed the container changes using

docker commit c4e5b242289c custom-n8n

This is how I’ll access it later:

docker run -d --name my-n8n-container -p 5678:5678 custom-n8n

Added some docker volumes to persist data

docker inspect c4e5b242289c | grep Mounts -A 10

Checked for other changes compared to the original image using

docker diff c4e5b242289c

If i want to revert it to the a clean version ChatGPT recommended me to run this:

docker stop c4e5b242289c
docker rm c4e5b242289c
docker run -d --name n8n-container -p 5678:5678 docker.n8n.io/n8nio/n8n

Hope this outlined my problem and thought process clearly. Happy building. Thank you for your input! It really helped as I have been facing this problem for days.

1 Like