Troubleshooting

2FA Code Not Working?

Eight fixes for invalid or expired 2FA codes: clock drift, wrong secret, stale code, time zone, and what to check before resetting anything.

Last updated: Oct 2, 2026 11:26:56

Your 2FA code is rejected. The first instinct is to reset the account — that is also the step most likely to lock you out for good. Almost every “invalid code” is one of eight causes below, and seven of them are fixed without touching the account settings.

Work top to bottom: the list is ordered by how often each cause actually occurs, not by how technical it sounds. Most people are finished after the first two.

Quick triage

Symptom Most likely cause Jump to
Code rejected, consistently, for days Clock drift on the device generating it Fix 1
Worked yesterday, fails today, nothing changed Clock drift, or the service rotated the secret Fix 1 / Fix 8
Two apps show different codes Wrong account entry, or different parameters Fix 2 / Fix 3
“Invalid code” only sometimes Code expiring between generation and submit Fix 5
Form rejects 6 digits, expects 8 Parameter mismatch Fix 3
Code field prefilled with an old value Browser or password manager autofill Fix 6
Everyone on the team is failing Service-side incident Fix 7

Fix 1: Make sure the clock is actually right

Why it happens. TOTP derives the code from the current time. Both sides must agree within one time step (usually 30 seconds). A device that is a minute off produces codes that are perfectly well-formed and always wrong.

How to check. Compare your device clock with a source that shows seconds, such as time.is. A difference under 10 seconds is fine; over 30 seconds is almost certainly the whole problem.

How to fix.

The trap. Time zone is not the issue. TOTP counts UTC seconds, so travelling from Shanghai to London changes nothing. Only the device’s absolute accuracy matters. Do not “fix” a code problem by changing the time zone.

Fix 2: Confirm you are looking at the right entry

Why it happens. One person, several accounts, identical issuer names. The app shows “Google — you@example.com” twice, and you open the personal one while logging into the work account.

How to check. Look at the label under the digits, not the digits themselves. In an authenticator app, tap the entry and read the full issuer and account name.

How to fix. Rename entries so they are distinguishable (work/personal), and delete duplicates you no longer use — a stale duplicate is worse than no duplicate, because it silently produces plausible wrong codes.

Fix 3: Check the parameters — digits, algorithm, period

Why it happens. A code is only correct for one combination of secret + algorithm + digit count + period. Six digits over 30 seconds with SHA-1 is the default, but it is not universal.

How to check. The setup link spells it out: otpauth://totp/Label?secret=…&digits=8&period=60&algorithm=SHA256. If the service has an admin console, the MFA policy page usually lists the same values.

How to fix. Match the parameters exactly. A 6-digit code in an 8-digit field fails even when the underlying integer is right, and SHA-256 versus SHA-1 changes every digit.

Diagnostic shortcut: if the first three or four digits match between your device and a working source, the secret and algorithm are right and you have a timing problem. If they differ entirely, you have a secret or parameter problem.

Fix 4: Verify the secret itself

Why it happens. Base32 uses A–Z and 2–7 only. A key that contains 0, 1 or 8 is not a Base32 key — it was mistyped, or OCR’d from a photo, or copied with a character substituted.

How to check.

How to fix. Re-copy from the source, one character at a time, and compare in pairs. If you only have a photo of a QR code, decode it with a reader that displays raw text rather than adding the account.

Fix 5: Use the newest code — not the one you already typed

Why it happens. A code generated at second 28 is dead two seconds later. If the login form is slow, or you switch apps to read the code, it can rotate before it is submitted.

How to fix.

Some services accept the previous and next step (a ±1 window), some accept only the current step. The stricter ones fail fast and look “randomly broken”.

Fix 6: Clear the stale autofill

Why it happens. Password managers and browsers sometimes treat the one-time-code field as a normal input and fill an old value, which the page submits on your behalf.

How to fix. Clear the field manually before typing (select all → delete), and mark the field as autocomplete="one-time-code" if you control the page. Then disable autofill for that specific site in your password manager.

Fix 7: Rule out a service-side problem

Why it happens. If everyone on the team is failing at once, the problem is upstream: an authentication service outage, a botched policy change, or server clocks out of sync.

How to check. Ask a colleague, or check the provider’s status page. If a second person with a different device has the same failure, stop troubleshooting your phone.

How to fix. Use a backup code, an already-signed-in session, or a recovery route. Do not re-enrol while an incident is in progress — you may lose the factor that would have worked once the service recovered.

Fix 8: Re-enrol — but only as a last resort

Why it happens. Occasionally the secret on the server and the secret in your app genuinely diverge: a partial reset, a migration, or an admin who removed and re-added the factor.

Before you reset, confirm three things:

  1. You still have working access to the account (a signed-in session, a recovery email, a backup code).
  2. You have read the first seven fixes. Re-enrolment does not fix a clock problem, and it destroys your only backup of a working secret.
  3. You know where the new backup codes will be stored.

After you reset: re-enrol the authenticator, save the new backup codes, remove the old device from the trusted list, and test the new code before closing the session.

Read the error message literally

Login pages are bad at explaining themselves, but the wording usually narrows the cause faster than any checklist:

Message What it usually means
“Invalid code” / “Code is incorrect” The value does not match any accepted time step — clock, secret or parameters
“Code expired” The step has already rotated; generate a fresh one and submit immediately
“Invalid credentials” The password is wrong; the code was never evaluated
“Too many attempts” Rate limiting — stop trying, wait, then use backup codes if needed
“Something went wrong” Often a server-side failure, not your input

One nuance: “invalid code” is frequently shown for any failed second-factor check, including ones caused by a wrong password retry. If you have been changing your password, verify that path first.

If you are already locked out

Repeated failures can trigger a lockout, and the fix is not more attempts. In order:

  1. Stop submitting. Most lockouts expire in 15–60 minutes; every retry restarts the clock.
  2. Use a backup code. It bypasses the authenticator entirely and is single-use.
  3. Use a signed-in session. An open browser or a mobile app that is already logged in can usually re-enrol the factor without a code.
  4. Try recovery. Recovery email, recovery phone, or the provider’s identity-verification process — this is why keeping those details current matters.
  5. Contact support with proof of identity. Expect it to take days, not minutes, for accounts holding money or business data.

The pattern that turns an inconvenience into a loss: no backup codes, stale recovery email, and a reset attempted during an outage. Any one of those is survivable; all three at once is not.

When the code is fine but the login still fails

Sometimes the digits are correct and the account is still unreachable — the password is wrong, the account is locked after failed attempts, or the service requires a step you have not completed (a CAPTCHA, a terms acceptance, a re-verification email). Read the error message literally: “invalid verification code” and “invalid credentials” are different failures with different fixes.

The thing you should fix today, not during an outage

Every account that offers 2FA offers backup codes. They are single-use strings that bypass the authenticator entirely — the only reliable answer to “my phone is gone”. Find them in the security settings, print them or store them in a password manager, and treat them like passwords.

Full detail, per platform, in 2FA backup codes.

Prevention checklist

If you still need to produce a code by hand, the 2FA code generator runs locally and shows you the six digits from a setup key; the TOTP generator is the same tool with every parameter exposed. For the underlying mechanism, see what TOTP is.

First: does your generator produce the correct code?
Compare the same secret here to rule out a clock or parameter problem.

Open the generator

Frequently asked questions

Why does my 2FA code keep saying invalid?

In most cases the device generating the code has a clock more than 30 seconds off, or the code expired while it was being typed. Wrong digit count, a different account entry, and a service-side outage cover almost everything else.

Can a wrong time zone cause 2FA failure?

No. TOTP uses UTC seconds, so the time zone setting is irrelevant. A clock that is simply inaccurate is the real problem, whatever the time zone.

What should I do if I lost my phone?

Use a backup code first, then a signed-in session or the provider's recovery process. Re-enrolling is a last resort because it requires access you may not have.

Should I reset my 2FA?

Not until you have ruled out clock drift, wrong entry and parameter mismatch - resetting destroys your working secret and can lock you out if recovery details are stale.

How do I know if the service is down?

Ask a second person with a different device. If both fail at the same moment, stop troubleshooting your phone and use a backup code.

How do I fix clock drift?

Turn on automatic time synchronisation: "Set automatically" on phones, "Sync now" on Windows, "Set time and date automatically" on macOS. Then reopen the authenticator app.