Password recovery

Hi.

I am running a self-hosted n8n with Docker and after the update that introduced user creation I decided to go with it and set up the owner account, but now I can’t log in with the credentials I used.

I am still logged in with the previously implemented authorisation method, but when I try to open the link to my n8n instance I am redirected to the log in screen where my credentials don’t work.

I tried to change the password in the user settings menu, but it says my password is incorrect.
I haven’t set up SMTP yet, so maybe that has something to do with it. Maybe there needs to be an activation process via email before the credentials work.
Maybe I have in fact saved the wrong password, but nevertheless I am scared that when I log out now, there will be no way back in.

So my question is, how can I reset the user or find/change the passwords in any other way besides that in the user settings?
Is there a way to launch the login page the way that it was before without being redirected to the new one?

Best regards,
Rafal

Hey @Rafix,

This one has come up a few times recently, You can disable the usermanagent feature with an environment variable. What you can’t do though is recover a password as we store a hash which isn’t something that can be decrypted.

It could be easier to set up the SMTP options (I use mailersend as they have a very good free tier) but there are other options available.

1 Like

You could reset to state from before setting up user manager.
Do this on your database

delete from user;
delete from 'role';
update settings SET value = 'false' WHERE key = 'userManagement.isInstanceOwnerSetUp';

WARNING:
This will delete all users

Then restart your docker and n8n should show you register form

3 Likes

Hey @Jon
Thank you for you suggestion.
So do I understand correctly, that when I set up the SMTP options, I will have the ability to change the user (owner) password through email?

Thank you @Shirobachi
Are there the environment variables that @Jon is talking about?
This will delete the users I created with the recent update that has introduced such an option.
My credentials I am logged in with at the moment (how should I refer to this way of logging in BTW?) will remain intact and I will still be able to log in this way, right?

Hey @Rafix,

You got it, So if you had SMTP options set up you could just follow the email password reset process. The approach by @Shirobachi looks like it would do the job and you could then set up the account again.

2 Likes

Thank you so much.
I will try to deal with it the way you suggested.

Best regards

Hey @Jon
Sorry to bother you again.
Since my BASIC_AUTH session ended, I lost access to my self-hosted instance, so it was motivation enough to get to setting up the SMTP. I think I did what I was supposed to, but I am still getting the Recover password error: “Please contact your admin. n8n isn’t set up to send email right now.”

My docker-compose environment setting:

      - N8N_BASIC_AUTH_ACTIVE=false
      - N8N_BASIC_AUTH_USER
      - N8N_BASIC_AUTH_PASSWORD
      - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_TUNNEL_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
      - N8N_USER_MANAGEMENT_DISABLED=false
      - N8N_EMAIL_MODE
      - N8N_SMTP_HOST
      - N8N_SMTP_PORT
      - N8N_SMTP_USER
      - N8N_SMTP_PASS
      - N8N_SMTP_SENDER
      - N8N_SMTP_SSL

My .env file

# SMTP configuration
N8N_EMAIL_MODE=smtp
N8N_SMTP_HOST=smtp.gmail.com
N8N_SMTP_PORT=465
[email protected]
N8N_SMTP_PASS=mypass
N8N_SMTP_SENDER=N8N [email protected]_
N8N_SMTP_SSL=true

N8N_PROTOCOL=https

I restarted docker a couple of times using different configurations and I know I can delete BASIC_AUTH, but from what I understand it gets ignored anyway in this instance.

I am considering editing the database the way @Shirobachi instructed me, but that is something I still need to wrap my head around, as I need to learn what tools I need for that. Although here my question would be, will that delete all users meaning the users set us with user management not the basic authority, right?

Thank you for your assistance.
Best regards

Hey!

So if you remove users from db, you delete from about user management no basic auth.
Instead of docker-compose restart try this docker-compose stop && docker-compose start

BTW. @Jon what do you think about make some command or env what will restart user managenent?

1 Like

command or env what will restart user managenent

Hi all, just wanted to drop by and let you know this CLI command exists and works since [email protected]. It’ll also be added to the documentation soon. As you long as you are using this version (or a new one), you can run n8n user-management:reset inside your docker container. Afterwards, you can create a fresh owner account.

@msadig tested this today over here: Trouble to sign-in on self-hosted docker (web) - #3 by msadig

3 Likes

Thank you for your help.

I managed to get it working, following @Shirobachi’s advice.
I actually ended up changing the password in the db following @GlitchWitch’s advice in this thread as I wasn’t sure if I should delete all user roles.

Unfortunatelly @MutedJam, resetting the user management didn’t work for me for some reason, although I was on the most recent version (0.181.2) and received the confirmation.

I used the command:

docker exec -it <my-n8n-container-name> n8n user-management:reset

Maybe I did something wrong here.

Do you maybe have any idea why the SMTP is still not working?

I am still getting:

Thank you kindly for your assistance.

1 Like

I love this!

Did you try restart docker? Docker can be sometimes pretty tricky :smiley:

Try docker exec -it <my-n8n-container-name> /bin/sh this will log in inside container ;D Them type the command provided by @MutedJam

1 Like

So for the SMTP configuration, this one has worked for me in the past:

      - N8N_EMAIL_MODE=smtp
      - N8N_SMTP_HOST=smtp.sendgrid.net
      - N8N_SMTP_USER=apikey
      - N8N_SMTP_PASS=myApiKey
      - [email protected]
      - N8N_SMTP_PORT=465

So pretty similar to what you’ve been doing @Rafix, apart from a different email provider (and the sender value not using spaces, though I don’t think that would cause a problem). Is there a chance your environment variables haven’t been applied? Did you re-create your container after setting/changing them?

That didn’t do anything, even though I managed to successfully reset the database.
I did that both in /data and /bin/sh.

I used the following commands:

docker-compose down
docker-compose up 
docker-compose stop
docker-compose start
docker-compose restart

Should I have used docker-compose up --force-recreate then?

Thanks guys. I am learning a lot!:wink:

2 Likes

Should I have used docker-compose up --force-recreate then?

No, your commands are looking good to me. docker-compose down would remove your container and docker-compose up would already have re-created and re-started it, so no need for additional commands here.

Unfortunately I have no idea why emails can’t be sent from your instance. Perhaps you can share a full docker-compose.yml file (with all confidential values redacted, of course) using which this problem can be reproduced?

That didn’t do anything, even though I managed to successfully reset the database.

I wonder if there is a chance it was executed with the wrong user account and has instead reset the default SQLite database for that user rather than your actual Postgres database.

When using the n8n standard docker image, n8n runs as user node. So after logging into your docker container as described by @Shirobachi, try running su-exec node n8n user-management:reset (this should execute the command as user node). Make sure to restart your n8n container afterwards.

1 Like

This command is what worked for me after hours of resetting and looking through every thread. I am still not at all sure how I even got to the point needing to reset it. I have had the same password for 5 months and up until this week could not login.

1 Like

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