Guide

Locked out of the Magento 2 admin? Get back in from the command line.

Unlock a blocked admin user, create a new admin, or reset two-factor authentication, with bin/magento on the server. No database edits needed. Checked on Nov 5, 2026.

Step 1Unlock

Unlock a user after too many failed logins

After several wrong passwords Magento locks the account for a while. Unlock it at once by user name.

On your server

bin/magento admin:user:unlock admin_username

Step 2New admin

Create a new admin user

If nobody can log in, create a new administrator, sign in with it and change the old user's password from System, Permissions, All Users.

On your server

bin/magento admin:user:create \
  --admin-user=support_temp \
  --admin-password='Use-a-long-unique-password-1' \
  --admin-email=you@example.com \
  --admin-firstname=Temp --admin-lastname=Admin

Delete the temporary user once you are back in, and never reuse a password from another site.

Step 3Two-factor

Reset two-factor authentication

A new phone or a lost authenticator app blocks the second step. Reset the provider for that user and set it up again at the next login.

On your server

bin/magento security:tfa:reset admin_username google

google is the Google Authenticator provider; others are duo_security and u2fkey.

Step 4Unlock

Flush the cache and try again

Clear the cache so the admin reads the new settings, then sign in from a private browser window.

On your server

bin/magento cache:flush

Questions, answered.

ShopWhizzy support Magento since 2008

Talk to us
You can disable the module, but it protects the admin from stolen passwords. Reset it for the user instead.
bin/magento info:adminuri prints it.
Several failed logins lock the user for a while. Check that a password manager is not filling in an old password.
Yes. Open a ticket from your account and we unlock or reset the user for you.

Bring your store over. We move it for free.

Pick a plan, pick a platform, and your store is online before the coffee cools.

Prices include VAT. Server support on every plan.