Forgot my password

System Information
  • Strapi Version: “strapi”: “3.6.1”,
  • Operating System: MacOs Catalina 10.15.7
  • Database: SQL Light / from localhost
  • Node Version: v14.16.1
  • NPM Version: 6.14.12
  • Yarn Version: –

Hello !

I was working with localhost and I forgot about my password, I tried with recover by email and I didn’t get one email back with the recovery code. Perhaps because I was working with localhost.

What do I do?

1 Like

Try resetting your password using Strapi CLI.

Steps:

  1. Open terminal (iTerm, cmd, etc.) in your Strapi app directory.
  2. Run : yarn strapi admin:reset-user-password --email="YOUR_EMAIL" --password="YOUR_NEW_PASSWORD" (if you use Yarn). You may have to create alphanumeric password (according to Strapi), so weak password like 12345 might fail to reset your password.

If you use NPM, you probably should run npm run strapi admin:reset-user-password --email="YOUR_EMAIL" --password="YOUR_NEW_PASSWORD".

26 Likes

Although I use yarn to run and build my projects, I found this command only worked for me using npm. But it worked!

I am using npm. but I got the problem like

Finaly got the solution by

Step-1:
strapi console

Step-2

function changePassword(useremail, password) {
strapi.admin.services.user.findOne({ email: useremail }).then(u => {
if (u) {
strapi.admin.services.auth.hashPassword(password).then(hashedPassword => {
strapi.query(‘user’, ‘admin’).update({id: u.id }, { password: hashedPassword })
.then(() => console.log(‘Updated successfully.’))
.catch((ex) => console.error(‘Failed to update password.’, ex))
}).catch(ex => console.error(‘Failed to hash password and update it.’, ex));
} else {
console.error(‘Wrong email?? Please check your email’);
}
});
}
changePassword(‘username@username.com’, ‘newpassword’);

Hello, don’t work for me bc i forgot username so it tell me cannot findOne of undefined…

Thank you!
Strapi community is the best around.

I got an error /admin/telemetry-properties (2 ms) 401 when I tried logging in after changing the password using the command line.

Hello,

Thank, save my life <3

Regards,

thx so much

Can’t log in to Strapi app on Render production. Correct credentials work on dev. Error: “Invalid credentials.” No terminal access on Render. Can any help how to solve this?

Thank you!

Thanks for this! I have been struggling to find a solution to this as I was experiencing the same issue. I forgot the admin password but can’t reset it either

1 Like

Thanks for sharing this solution. I also struggled with it. Appreciate it. I solved it.

1 Like

Thank you!
Works for me.