CodeMismatchException Authentication Origin: Application & API OSI layer 7 · Application Last updated 28 Nov 2026

AWS Cognito: CodeMismatchException: Invalid verification code provided, please try again

The confirmation or MFA code entered does not match what Cognito sent.

Exact message you may see Invalid verification code provided Cognito
Seen on: AWS

Meaning

Confirmation, password-reset and MFA codes are single use. If the user requested a second code the first stops working, so a code copied from an older email or SMS is rejected with CodeMismatchException.

Common causes

  • Typo in the code
  • Older code used after a resend
  • Code for a different user
  • MFA code expired
  • Code typed for a different user pool client

⚡ Quick fix

  1. Request a new code and use the latest
  2. Check the username used
  3. Show a resend button and tell users to use the newest code
  4. Compare the username used for request and confirmation

Detailed fix by platform

AWS CLI

  1. aws cognito-idp resend-confirmation-code --client-id ID --username USER

How to diagnose

  1. Code — Latest code?
  2. User — Same username?
  3. Time — Within expiry?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

ExpiredCodeException — AWS Cognito: ExpiredCodeException: Invalid code provided, please request a code again (Authentication)ExpiredCodeExceptionInvalidPasswordException — AWS Cognito: InvalidPasswordException: Password did not conform with policy (Authentication)InvalidPasswordExcept…LimitExceededException — AWS Cognito: LimitExceededException: Attempt limit exceeded, please try after some time (Authentication)LimitExceededExceptionNotAuthorizedException — AWS Cognito: NotAuthorizedException: Incorrect username or password (Authentication)NotAuthorizedExceptionRefresh Token has been revoked — AWS Cognito: NotAuthorizedException: Refresh Token has been revoked (Authentication)Refresh Token has bee…Unable to verify secret hash for client — AWS Cognito: NotAuthorizedException: Unable to verify secret hash for client x (Authentication)Unable to verify secr…UsernameExistsException — AWS Cognito: UsernameExistsException: User already exists (Authentication)UsernameExistsExcepti…UserNotConfirmedException — AWS Cognito: UserNotConfirmedException: User is not confirmed. (Authentication)UserNotConfirmedExcep…CodeMisma…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.