# An error occurred (UserNotFoundException) when calling the AdminGetUser operation: User not found

- **ID:** `aws/cognito-user-not-found-exception`
- **Domain:** aws
- **Category:** auth_error
- **Error Code:** `UserNotFoundException`
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

The specified user does not exist in the Amazon Cognito user pool, possibly due to incorrect username, user deletion, or using a user pool ID from a different environment.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Cognito User Pools API 2016-04-18 | active | — | — |
| AWS SDK for JavaScript 3.600.0 | active | — | — |

## Workarounds

1. **Verify the username exists by listing users in the pool: `aws cognito-idp list-users --user-pool-id <pool-id> --query "Users[?Username=='<username>']"`. If missing, re-create the user with `aws cognito-idp admin-create-user --user-pool-id <pool-id> --username <username>`.** (95% success)
   ```
   Verify the username exists by listing users in the pool: `aws cognito-idp list-users --user-pool-id <pool-id> --query "Users[?Username=='<username>']"`. If missing, re-create the user with `aws cognito-idp admin-create-user --user-pool-id <pool-id> --username <username>`.
   ```
2. **Check that the user pool ID in the request matches the correct environment (dev vs prod) and that the user was not accidentally deleted via AWS Console or API.** (85% success)
   ```
   Check that the user pool ID in the request matches the correct environment (dev vs prod) and that the user was not accidentally deleted via AWS Console or API.
   ```

## Dead Ends

- **Re-running the same AdminGetUser call with the same credentials, expecting a different result.** — The user truly does not exist; retrying does not create or recover the user. (100% fail)
- **Modifying IAM permissions to allow all cognito-idp actions, assuming it's a permission issue.** — The error is UserNotFoundException, not AccessDenied; permissions are sufficient. (80% fail)
