Black Friday: 60% off yearly plans with code BF2026, until November 30. See the deal

Troubleshooting

Locked out of WordPress admin: WordPress reset admin password

If you are locked out of WordPress admin, try the Lost your password link first, then reset the password with WP-CLI (wp user update ID --user_pass=NEW) if you have shell access. Database edits and a temporary functions.php line are the fallbacks when email is broken.

The short answer
  • Start with the Lost your password link. It needs working email on the site.
  • WP-CLI resets a password in one command and needs no email.
  • Any temporary script or code you add must be removed straight afterward.

Which reset method should you use?

Password reset methods from the WordPress documentation
MethodYou needWatch out for
Lost your password? link on wp-login.phpUsername or email, and working site emailMail not arriving is the most common reason this fails
WP-CLI: wp user updateShell access and the user IDRun wp user list first to find the ID
phpMyAdmin or MySQL: edit user_passDatabase accessMistakes can damage data, WordPress states use is at your own risk
FTP: add wp_set_password to functions.phpFTP access to the active themeResets the password on every page load until you remove the line
Emergency password reset scriptFile access and the administrator usernameDelete it as soon as you finish

What are the exact commands?

WP-CLI and functions.php methods
# WP-CLI: find the user ID, then set a new password
wp user list
wp user update 1 --user_pass=NEW_STRONG_PASSWORD

# or generate a reset without choosing the password
wp user reset-password 1

// functions.php (temporary, remove after login)
wp_set_password( 'my_new_password', 1 );

See Reset your password and wp user reset-password. The 1 is the user ID, usually the main administrator.

What if the problem is not the password?

  1. 01

    Check you are on the right site

    Staging, old domains and client copies share the same login screen. Confirm the URL and whether the site moved.

  2. 02

    Clear cookies and try a private window

    A stale cookie after a domain or HTTPS change can loop you back to the login page.

  3. 03

    Deactivate plugins over FTP

    A security or two-factor plugin can lock out every user. Rename wp-content/plugins and try again.

  4. 04

    Check the site and WordPress URL values

    Wrong WP_HOME or WP_SITEURL values cause redirect loops. See wp-config.php.

Agencies: do not share one admin login

Give each person their own named administrator user and remove users when people leave. Lockouts caused by a shared password change are common and make audit trails useless.

What should you do right after you are back in?

  • Remove any temporary code or script you added, including emergency.php and the functions.php line
  • Set a strong, unique password and store it in a password manager
  • Check the user list for administrators you do not recognize
  • Turn on two-factor authentication if a plugin on the site supports it

Common questions

How do I reset my WordPress admin password?

Use the Lost your password link on wp-login.php if site email works. Otherwise, with shell access run wp user update followed by the user ID and --user_pass=NEWPASSWORD. As a last resort edit user_pass in the database or use the documented functions.php method.

What if I do not receive the reset email?

The site may not be able to send mail, or the message may land in spam. Reset with WP-CLI, phpMyAdmin or the functions.php method instead, which do not depend on email, then configure mail sending so it works next time.

Is the functions.php password trick safe?

It works, but WordPress warns it resets the password on every page load until you remove the line. Add it, log in, then delete it immediately. Use it only over a secure connection, and change the password afterward.

How can I add a new administrator over FTP or SSH?

With WP-CLI run wp user create with a username, email and --role=administrator. This avoids touching the existing account and leaves a clear record of who was added.

Why does WordPress keep redirecting me to the login page?

A login loop usually comes from stale cookies, a changed site URL or a security plugin. Clear cookies or use a private window, check WP_HOME and WP_SITEURL in wp-config.php, and rename the plugins folder over FTP to rule out a security plugin.

Watch your domains automatically

Aepto monitors expiry, DNS, SSL and uptime for every domain you own and alerts you when something changes. Free for 3 domains.