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

**Code:** `CodeMismatchException` · **Category:** Authentication · **Seen on:** AWS

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

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/auth/cognito-codemismatch)
