In this post I am going to explain how to unlock admin user via command line in Magento 2.

First login to SSH panel and navigate to Magento 2 setup root.

Run the following command. It will show usage of the command.


Unlock Admin Account

admin:user:unlock <username>

username The admin username to unlock

-h, –help Display this help message
-q, –quiet Do not output any message
-V, –version Display this application version
–ansi Force ANSI output
–no-ansi Disable ANSI output
-n, –no-interaction Do not ask any interactive question
-v|vv|vvv, –verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

This command unlocks an admin account by its username.
To unlock:
bin/magento admin:user:unlock username

Syntax to Unlock Admin user:


For example, If you want to unlock a admin account with username “johndoe” then,

php bin/magento admin:user:unlock johndoe


“The user account “johndoe” has been unlocked”

If the admin user was not locked then you will get below message.

“The user account “johndoe” was not locked or could not be unlocked”