WordPress Plugins
Free Tools
Claude Skills
Resources
Pricing Support My Account Cart
Security

WordPress 2FA Recovery: How to Regain Access When Locked Out

By Jameson · Updated Nov 3, 2026 · 8 min read

To get back into WordPress after losing your 2FA device, work down this list: (1) type a saved backup code into the 2FA code field, (2) ask another administrator to turn off 2FA on your profile, (3) on GuardPress, add define( 'GUARDPRESS_2FA_DISABLED', true ); to wp-config.php, (4) delete your 2FA record in the database (the table depends on the plugin), or (5) deactivate the 2FA plugin by renaming its folder in wp-content/plugins/. Methods 3 and 5 take about a minute if you can reach your site's files.

You enabled two-factor authentication on your WordPress site, the single best thing you can do to prevent unauthorized logins. Then your phone broke, you switched devices, or you accidentally deleted your authenticator app. Now you're staring at a 2FA prompt with no way to generate a valid code.

This is one of the most common WordPress lockout scenarios, and it's almost always recoverable. The key is knowing which recovery method to try first and in what order.

This guide covers five recovery methods, from typing a backup code to editing the database, with the exact steps for GuardPress, Wordfence, the Two Factor plugin and WP 2FA.

Why You're Locked Out of WordPress 2FA

Two-factor authentication uses time-based one-time passwords (TOTP) that are generated by an authenticator app on your device. The app and your server share a secret key, and both use the current time to calculate matching 6-digit codes every 30 seconds.

When that chain breaks, you lose access. The most common causes:

  • Lost or broken phone: your authenticator app was on a device you no longer have
  • Deleted authenticator app: accidentally removed without backing up your accounts
  • New phone without transfer: upgraded devices and didn't migrate your authenticator data
  • App data corrupted: authenticator reset itself after an OS update or restore
  • Time sync issues: codes are rejected because your device clock is off by more than 30 seconds
Before You Panic

If your codes are being rejected but you still have the authenticator app, the issue might be clock drift. Check the time sync fix at the bottom of this article before trying the recovery methods.

Method 1: Use Your Backup Recovery Codes

This is the fastest recovery method and the one you should always try first. When you set up 2FA, your security plugin gave you a set of one-time backup codes (GuardPress generates 10). If you saved them, you're 30 seconds away from being back in.

  1. Go to your WordPress login page and enter your username and password as normal
  2. On the 2FA prompt, enter one of your backup codes instead of the 6-digit app code. In GuardPress the backup code goes into the same Two-Factor Authentication Code field; some other plugins show a separate backup-code link on the prompt
  3. Each code works once, so cross it off after you use it
  4. Once logged in, open your profile, pair your new device and generate a fresh set of codes
Where to Find Your Recovery Codes

Check your password manager (1Password, Bitwarden, LastPass), secure notes app, any printed backup you stored in a safe place, or your email (you may have sent them to yourself). GuardPress Pro shows the codes once during setup and won't let you finish until you confirm you've saved them.

Method 2: Ask Another Administrator

If you didn't save your recovery codes but there's another admin who can sign in, this is the next easiest fix. They can turn off 2FA on your account from your profile, with no technical steps.

  1. Have the other administrator log into the WordPress dashboard
  2. Navigate to Users → All Users and click "Edit" on your profile
  3. Scroll to the Two-Factor Authentication section and turn it off. In GuardPress the button is Disable Two-Factor Authentication, and WordPress asks the admin to confirm with their own password
  4. Log in with just your password and set up 2FA again on your current device

WP 2FA's own documentation recommends this as the first step too. It's why every WordPress site should have at least two administrator accounts.

Method 3: Turn Off GuardPress 2FA From wp-config.php

If you use GuardPress and can reach your site's files, this is the cleanest fix: one line in wp-config.php switches off the 2FA check while you sign in, and the rest of GuardPress (firewall, login limits, scanning) keeps running.

  1. Open wp-config.php in your host's file manager or over SFTP. It sits in your site's root folder, next to wp-content
  2. Add this line above the line that says /* That's all, stop editing! */:
    define( 'GUARDPRESS_2FA_DISABLED', true );
  3. Sign in with your username and password. No 2FA prompt appears
  4. Go to your profile, disable and re-enable 2FA to pair your new device, and save the new backup codes
  5. Delete the line from wp-config.php so 2FA is enforced again
Remove the Line Straight Away

While the constant is set, no account on the site is asked for a 2FA code. Treat it as a two-minute switch, not a setting.

Method 4: Remove Your 2FA Record in the Database

If you're the only admin and didn't save recovery codes, you can delete your 2FA record directly. Each plugin stores it in a different place, so pick the query for the plugin you use.

Step 1: Open phpMyAdmin (or WP-CLI)

Log into your hosting control panel (cPanel, Plesk, or your host's dashboard) and open phpMyAdmin. Most hosts have a direct link in their database section. If you have SSH, you can run the same queries with wp db query.

Step 2: Find Your User ID

Run this query to find your WordPress user ID:

SELECT ID, user_login FROM wp_users
WHERE user_login = 'your_username';

Step 3: Delete Your 2FA Record

Replace 123 with your user ID from Step 2 and run the query for your plugin:

PluginWhere it stores 2FAQuery
GuardPresswp_gp_two_factor tableDELETE FROM wp_gp_two_factor WHERE user_id = 123;
Wordfence Login Securitywp_wfls_2fa_secrets tableDELETE FROM wp_wfls_2fa_secrets WHERE user_id = 123;
Two Factor (WordPress.org plugin)user metaDELETE FROM wp_usermeta WHERE user_id = 123 AND meta_key IN ('_two_factor_enabled_providers', '_two_factor_provider');

With WP-CLI the GuardPress version is wp db query "DELETE FROM wp_gp_two_factor WHERE user_id = 123;", and for the Two Factor plugin wp user meta delete 123 _two_factor_enabled_providers. For WP 2FA and other plugins, use Method 2 or Method 5, as WP 2FA's own documentation does.

Step 4: Log In and Reconfigure

2FA is now off for your account. Log in with just your password and set 2FA up again. If your site requires 2FA for your role, the plugin will ask you to set it up as you sign in. Save your recovery codes this time.

Table Prefix May Differ

The queries above use the default wp_ table prefix. If your site uses a custom prefix, check wp-config.php for the $table_prefix value and adjust the table names. Take a database backup before running any DELETE.

Method 5: Temporarily Disable the Plugin via FTP

If you can't use any of the methods above, deactivate the whole 2FA or security plugin by renaming its folder. This removes 2FA enforcement completely until you rename it back.

  1. Connect via FTP/SFTP: use FileZilla, your hosting's file manager, or any SFTP client
  2. Navigate to /wp-content/plugins/ and find the plugin's folder: guardpress for GuardPress, wordfence for Wordfence, two-factor for Two Factor, wp-2fa for WP 2FA
  3. Rename the folder: for example, change guardpress to guardpress-disabled. WordPress deactivates the plugin automatically
  4. Log into WordPress: with the plugin disabled, 2FA is not enforced
  5. Rename the folder back to its original name, reactivate the plugin in the dashboard, and reconfigure 2FA with recovery codes properly saved

With SSH access, wp plugin deactivate guardpress (or the plugin's folder name) does the same in one command.

Security Warning

While the security plugin is disabled, your site loses all its protections (firewall, login limiting, malware scanning, etc.). Complete this process as quickly as possible and re-enable the plugin immediately after reconfiguring 2FA.

Fixing Time Sync Issues (Codes Rejected)

If you still have your authenticator app but codes keep getting rejected, the problem is almost certainly clock drift. TOTP codes are time-sensitive. If your device clock is off by even 30-60 seconds, every code will be invalid.

  • Enable automatic time: on your phone, go to Settings → Date & Time and enable "Set automatically"
  • Google Authenticator (Android): open the app, tap the three-dot menu, go to Settings → Time correction for codes → Sync now
  • Server time: contact your host to verify the server's NTP synchronization is working correctly
  • Try adjacent codes: the code changes every 30 seconds, so try the code immediately before or after it transitions

How to Prevent Future 2FA Lockouts

Getting locked out once is a learning experience. Getting locked out twice is a process failure. Set up these safeguards now:

  • Save recovery codes in a password manager: 1Password, Bitwarden, and LastPass all have secure notes features perfect for this
  • Use a cloud-synced authenticator: Authy, 1Password, and Microsoft Authenticator can sync your 2FA accounts across multiple devices, so losing one phone doesn't lock you out
  • Set up 2FA on a second device: scan the QR code on both your phone and a tablet during initial setup
  • Save the QR code securely: screenshot the setup QR code and store it in encrypted storage (not your camera roll)
  • Maintain a second admin account: a separate administrator with independent 2FA gives you a backdoor without compromising security
  • Verify your site after recovery: run our free Security Scanner to confirm nothing was tampered with while your plugin was disabled
Recommended Authenticator Apps

Authy: cloud backup and multi-device sync (our top recommendation). 1Password: stores 2FA tokens alongside your passwords. Microsoft Authenticator: cloud backup option with enterprise features.

Frequently Asked Questions

Can I recover my WordPress account if I lost my authenticator app?

Yes. Try these in order: type a saved backup code into the 2FA field, ask another administrator to turn off 2FA on your profile, add define( 'GUARDPRESS_2FA_DISABLED', true ); to wp-config.php if you use GuardPress, delete your 2FA record in the database, or deactivate the plugin by renaming its folder in wp-content/plugins/ over FTP.

Where do I find my WordPress 2FA backup recovery codes?

Recovery codes are generated when you first enable two-factor authentication. Check your password manager, secure notes app, printed backups, or email (you may have sent them to yourself). If you didn't save them, you'll need to use an alternative recovery method such as database access or FTP.

Why are my WordPress 2FA codes not working even though I have the authenticator app?

TOTP codes depend on accurate time synchronization. If your phone's clock is even slightly off, codes will be rejected. Enable automatic time sync on your device. In Google Authenticator, go to Settings → Time correction for codes → Sync now. Also verify your hosting server's NTP sync is working correctly.

How do I prevent getting locked out of WordPress 2FA in the future?

Save your recovery codes in a password manager, use a cloud-synced authenticator app like Authy or 1Password, set up 2FA on a secondary device as backup, save the setup QR code in encrypted storage, and ensure at least one other administrator has independent access to the site.

I'm the only admin, I lost my phone and never saved backup codes. What's the fastest fix?

If you can reach your site's files through your host's file manager or SFTP, you can be back in within a minute. On GuardPress, add define( 'GUARDPRESS_2FA_DISABLED', true ); to wp-config.php, sign in, pair your new phone, then delete the line. On any other plugin, rename its folder in wp-content/plugins/, sign in, rename it back and set up 2FA again.

Where do GuardPress, Wordfence and the Two Factor plugin store 2FA settings?

GuardPress uses its own wp_gp_two_factor table, Wordfence Login Security uses the wp_wfls_2fa_secrets table, and the Two Factor plugin uses user meta (_two_factor_enabled_providers and _two_factor_provider). Deleting your row or meta turns 2FA off for your account. Adjust the wp_ prefix if your site uses a custom one.

Protect Your WordPress Site with GuardPress Pro

Two-factor authentication, firewall, malware scanning, and login protection. All in one lightweight security plugin with built-in recovery tools.

GET PROTECTED