Title: Invalid Code error with 2FA when logging in
Last modified: November 8, 2023

---

# Invalid Code error with 2FA when logging in

 *  Resolved [rapx21](https://wordpress.org/support/users/rapx21/)
 * (@rapx21)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/invalid-code-error-with-2fa-when-logging-in/)
 * Hello,
 * When I try to log in, the error message “CODE INVALID: The 2FA code provided 
   is expired or invalid. Please try again.” appears.
   The 2FA has always worked 
   fine, only now it’s giving me this error.
 * I’ve already emailed the diagnostic file.
 * Best regards,
   Rui Raposo

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Support [wfmark](https://wordpress.org/support/users/wfmark/)
 * (@wfmark)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/invalid-code-error-with-2fa-when-logging-in/#post-17185738)
 * Hello [@rapx21](https://wordpress.org/support/users/rapx21/), and thanks for 
   reaching out to us and sending the diagnostic report.
 * This normally occurs when there’s a time offset on your site or device time. 
   From the diagnostic, that looks good.
 * Does the same issue occur with both your 2FA app’s generated code AND your backup
   recovery code(s)? I just wanted to check whether you’d been able to try both 
   methods.
 * You could check whether there are any JavaScript errors in your [browser console](https://www.wordfence.com/help/advanced/troubleshooting/#how-to-inspect-the-browser-console)
   on that page, then paste me a screenshot of what you’re seeing. However, if you
   need immediate access back I’m happy to provide you with instructions:
    - Please use FTP/SFTP — or any file manager your web host provides via their
      administration panel.
    - Look inside the **/wp-content/plugins/** directory and rename the **wordfence**
      directory to **wordfence.bak**. This will deactivate Wordfence and allow you
      to login without the 2FA code.
    - Once you have logged in to your WordPress admin you can name the folder back
      to **wordfence** again.
    - Go to your user profile and add 2FA back to your account, making sure to download
      the backup codes in case of problems in the future.
 * If you have any other trouble logging in,  feel free to reach out here.
 * Thanks,
 * Mark.
 *  Thread Starter [rapx21](https://wordpress.org/support/users/rapx21/)
 * (@rapx21)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/invalid-code-error-with-2fa-when-logging-in/#post-17186137)
 * Hello Mark,
 * Thanks for your reply.
 * You can close the ticket. I found the error, the user was using the generator
   from another user. Thank you.
 * Best regards,
   Rui
    -  This reply was modified 2 years, 7 months ago by [rapx21](https://wordpress.org/support/users/rapx21/).
    -  This reply was modified 2 years, 7 months ago by [rapx21](https://wordpress.org/support/users/rapx21/).
    -  This reply was modified 2 years, 7 months ago by [rapx21](https://wordpress.org/support/users/rapx21/).

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Invalid Code error with 2FA when logging in’ is closed to new replies.

 * ![](https://ps.w.org/wordfence/assets/icon.svg?rev=2070865)
 * [Wordfence Security - Firewall, Malware Scan, and Login Security](https://wordpress.org/plugins/wordfence/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordfence/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordfence/)
 * [Active Topics](https://wordpress.org/support/plugin/wordfence/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordfence/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordfence/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [rapx21](https://wordpress.org/support/users/rapx21/)
 * Last activity: [2 years, 7 months ago](https://wordpress.org/support/topic/invalid-code-error-with-2fa-when-logging-in/#post-17186137)
 * Status: resolved