🔧 Flat-price WordPress fixes from $69 — start with a free diagnosis, no card. Get a free diagnosis →

Errors

Locked Out of WordPress Admin? 5 Ways to Regain Access

Aug 22, 2026 · 7 min read · By the Mend engineering team

To regain access when locked out of the WordPress admin dashboard, you can bypass the standard login interface using database or server file access. The fastest safe methods include creating a new administrator user via phpMyAdmin, inserting an emergency admin snippet into your active theme's functions.php file, or temporarily disabling security plugins via FTP. Always take a complete site and database backup before making changes to server files or database tables.

Being locked out of your own WordPress website is frustrating, but it happens to almost every site owner eventually. Whether an automated security plugin blocked your IP address, a password reset email failed to deliver, or a PHP code error rendered wp-admin inaccessible, you are not permanently locked out. This guide covers the safe, proven ways to bypass the front-door login page and restore administrative control.

What You Are Seeing: Common Admin Lockout Symptoms

Admin lockouts take several forms depending on what triggered the lock. Identifying the exact behavior helps narrow down the solution:

  • The Password Reset Email Never Arrives: You click "Lost your password?", enter your username or email address, but no confirmation email ever lands in your inbox or spam folder.
  • Security Plugin IP Lockout: You see a message such as "Access Denied," "Your IP has been flagged," or a 403 Forbidden error immediately upon accessing wp-admin or wp-login.php.
  • Two-Factor Authentication (2FA) Trap: You replaced your phone, lost access to your authenticator app, or lost your backup codes, leaving you unable to complete the second step of logging in.
  • Blank Screen or Fatal Error on Login: Submitting your correct username and password results in a completely white screen or a "There has been a critical error on this website" message.
  • Endless Login Redirect Loops: Entering valid credentials simply refreshes the login page or redirects you in a loop without loading the dashboard. (If you suspect a loop, read our detailed guide on fixing the WordPress login redirect loop).

Why WordPress Admin Lockouts Happen

When WordPress blocks an administrator, it is usually due to one of three underlying system mechanisms:

  1. Failed Email Delivery: Default WordPress password resets rely on the native PHP mail() function. Most web hosts limit or block unauthenticated PHP mail to prevent spam, causing reset emails to silently fail.
  2. Overzealous Security Rule Sets: Security plugins keep bad actors out by imposing rate limits, blocking specific IP addresses, or enforcing strict 2FA. If you make a few typos in your password or your ISP changes your public IP, the plugin treats you like an attacker. (Learn more about defending against malicious attempts in our guide on how to stop WordPress brute-force login attacks).
  3. Database or Session Mismatches: Incorrect site URL constants, corrupted user permissions (capabilities) in the database, or browser cookie conflicts can prevent WordPress from establishing an authenticated session.

5 Step-by-Step Ways to Regain Access to WordPress

Safety Warning: Before proceeding with any database edits or file modifications, log into your web hosting control panel (cPanel, Plesk, or your host's dashboard) and create a full backup of your website files and MySQL database. For an overall overview of recovery paths, refer to our comprehensive guide on recovering from WordPress admin lockouts.

Method 1: Create a New Admin User via phpMyAdmin (Safest & Direct)

If password reset emails are failing, creating a brand-new administrator account directly inside your WordPress database gives you immediate access without touching existing user accounts.

  1. Log into your hosting account control panel and launch phpMyAdmin.
  2. Select your website's database from the left-hand menu.
  3. Locate your table prefix (by default it is wp_, but it may be customized like wp_xyz123_). Click on the SQL tab at the top.
  4. Copy and paste the following SQL query into the box, replacing wp_ with your site's actual database prefix if different:
INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`, `display_name`)
VALUES ('tempadmin', MD5('ComplexPassword123!'), 'tempadmin', '[email protected]', '0', 'Temp Admin');

INSERT INTO `wp_usermeta` (`user_id`, `meta_key`, `meta_value`)
VALUES ((SELECT `ID` FROM `wp_users` WHERE `user_login` = 'tempadmin'), 'wp_capabilities', 'a:1:{s:13:"administrator";b:1;}');

INSERT INTO `wp_usermeta` (`user_id`, `meta_key`, `meta_value`)
VALUES ((SELECT `ID` FROM `wp_users` WHERE `user_login` = 'tempadmin'), 'wp_user_level', '10');

Click Go to execute the query. You can now log into your domain.com/wp-admin using the username tempadmin and password ComplexPassword123!. Once inside, change the password immediately or reset your main user account password from the Users screen.

Method 2: Create an Emergency Admin Account via functions.php

If you have FTP access or File Manager access in your hosting dashboard, you can trigger WordPress to create an admin account using PHP code when the page loads.

  1. Connect to your site via FTP or open your hosting File Manager.
  2. Navigate to /wp-content/themes/your-active-theme/.
  3. Download and edit the functions.php file.
  4. Add the following code block at the very bottom of the file, just before any closing ?> tag (if present):
function mend_emergency_admin_user() {
    $username = 'emergencyadmin';
    $password = 'SecurePass987!';
    $email    = '[email protected]';

    if ( ! username_exists( $username ) && ! email_exists( $email ) ) {
        $user_id = wp_create_user( $username, $password, $email );
        $user = new WP_User( $user_id );
        $user->set_role( 'administrator' );
    }
}
add_action( 'init', 'mend_emergency_admin_user' );
  1. Save the file and upload it back to your server.
  2. Visit your website's home page once in your browser to execute the code.
  3. Log into /wp-admin with username emergencyadmin and password SecurePass987!.
  4. Crucial Step: Immediately remove that code snippet from your functions.php file and save it, otherwise it will try to re-run on every page load.

Method 3: Reset Existing User Password in phpMyAdmin

If you prefer to update your existing password rather than creating a new user:

  1. Open phpMyAdmin and click on the wp_users table.
  2. Find your administrator username in the user_login column and click Edit.
  3. Locate the user_pass field. In the Function dropdown menu on the left, select MD5.
  4. In the Value field, delete the hashed string and type your new plain-text password.
  5. Click Go at the bottom of the page to save. phpMyAdmin will hash the password securely, allowing you to log in.

Method 4: Bypass Security Plugins or 2FA via FTP

If a security plugin (like Wordfence, Solid Security, or a 2FA plugin) has locked your IP address or is demanding a token you don't have, disabling the plugin directory temporarily will instantly deactivate its restrictions.

  1. Connect to your server using FTP or File Manager.
  2. Navigate to /wp-content/plugins/.
  3. Locate the folder of the security plugin causing the lockout (e.g., wordfence, better-wp-security, or two-factor).
  4. Rename the folder by adding _disabled to the end (e.g., wordfence_disabled).
  5. Try accessing /wp-admin again. WordPress will automatically deactivate the missing plugin and let you log in normally.
  6. Once inside, you can rename the plugin folder back to its original name and adjust the security or 2FA settings that locked you out.

Method 5: Override Site URLs in wp-config.php

If you recently moved your site, added an SSL certificate, or changed settings in Settings > General, incorrect URL definitions can cause immediate logout loops.

To force the correct site addresses and regain access, open your root wp-config.php file via FTP and add these lines above the line that says /* That's all, stop editing! Happy publishing. */:

define( 'WP_HOME', 'https://yourdomain.com' );
define( 'WP_SITEURL', 'https://yourdomain.com' );

Replace https://yourdomain.com with your actual domain URL (ensure http vs https and www vs non-www matches your server setup). Save and reload your login screen.


How to Prevent Future Admin Lockouts

Once you are back inside your dashboard, take these steps to make sure you never get locked out again:

  • Configure Reliable Transactional Email: Install an SMTP plugin (such as WP Mail SMTP) paired with SendGrid, Postmark, or Mailgun so password reset emails deliver reliably every time.
  • Keep Backup 2FA Emergency Codes: When enabling Two-Factor Authentication, store recovery codes in an encrypted password manager.
  • Maintain a Secondary Admin Account: Keep an unadvertised, secondary administrator account with a unique password for back-door access if your primary account experiences issues.
  • Set Up Staging Environments: Test major updates or security plugin configuration changes on a staging server before applying them to your live website.

When to Call a Professional Engineer

While the step-by-step methods above solve the vast majority of login issues, certain scenarios require deeper investigation:

  • You suspect malicious code or malware is actively deleting admin users or intercepting your database updates.
  • You do not have access to hosting control panels, FTP, or phpMyAdmin credentials.
  • The site throws database connection errors or syntax errors that prevent database tools from running.

If you are stuck, pressed for time, or worried about making database mistakes on a live site, our team of senior WordPress engineers can safely restore access for you. You can request a Quick Fix for standard lockout issues, or submit a Emergency Rescue request if your site is completely offline. Granting access is seamless and secure using our free Mend Connect plugin, backed by our clear fix-or-your-money-back guarantee.

Frequently asked questions

What is the fastest way to get back into WordPress if I forgot my password?

If the password reset email does not arrive, the fastest safe method is editing your user's password in phpMyAdmin. Locate your user in the `wp_users` table, change the `user_pass` field function to MD5, enter your new password, and save.

Will disabling a security plugin via FTP delete my security settings?

No. Renaming a plugin folder in `wp-content/plugins/` merely deactivates it inside WordPress. Your settings remain safely stored in the MySQL database and will be restored when you rename the folder back to its original name.

Why are WordPress password reset emails not sending?

Most web hosts disable or restrict the default PHP `mail()` function to prevent server abuse. Without an authenticated SMTP plugin configured on your site, automated emails like password resets are blocked before leaving the server.

How do I remove a temporary admin user created during emergency access?

Log into your WordPress dashboard with your primary account, navigate to Users > All Users, hover over the temporary account name, and click Delete. Make sure to attribute any content owned by that user to your primary account.