Amazon Cognito says the user pool client does not exist
ResourceNotFoundException: User pool client 1example23456789 does not exist.Short answer
Cognito looks the app client ID up inside the Region you call. ResourceNotFoundException means that lookup found nothing. Either the ID is not an app client of that pool, the client was deleted, or your SDK calls a different Region than the one holding the pool. List the pool's clients in the right Region and compare the IDs.
Fix it fast
1Find out which cause you have
List the app clients of the user pool, in the Region where the pool lives (pool IDs look like us-west-2_EXAMPLE). Then compare the ClientId values with the ID in your error.
aws cognito-idp list-user-pool-clients --user-pool-id us-west-2_EXAMPLE --region us-west-22Match what you see, then jump to its fix
- 1
The ID in the error is missing from the list-user-pool-clients output, but the pool shows other clients.The client ID belongs to another app client, pool or environmentFix - 2
The ID matches your config, but it is not in the list, and someone recently rebuilt the pool or cleaned up clients.The app client was deletedFix - 3
The client is visible in the console or CLI in one Region, but the app's requests go to a cognito-idp endpoint of another Region.The app calls a different Region than the one holding the poolFix
- 1
What does the error look like?
ResourceNotFoundException: User pool client 1example23456789 does not exist.ResourceNotFoundException (HTTP status code 400) returned by InitiateAuth
Cause 1 of 3
The client ID belongs to another app client, pool or environment
1Check
Each app client has its own ID, and it belongs to exactly one user pool. A typo, an ID copied from a staging or test pool, or the ID of a second app in the same pool all give this error. The list output shows ClientId, ClientName and UserPoolId for every client.
aws cognito-idp describe-user-pool-client \
--user-pool-id us-west-2_EXAMPLE \
--client-id 1example23456789 \
--region us-west-22Fix
Copy the ClientId of the client your app should use from the list output into the app's configuration and redeploy the app. Check that the user pool ID in the same config matches the pool you listed.
# .env of the app (names are yours; the values come from the list output)
COGNITO_USER_POOL_ID=us-west-2_EXAMPLE
COGNITO_CLIENT_ID=1example234567893Verify
describe-user-pool-client returns the details of that client. Then repeat the sign-in that failed.
aws cognito-idp describe-user-pool-client --user-pool-id us-west-2_EXAMPLE --client-id 1example23456789 --region us-west-2Confirmed by docs.aws.amazon.com
Cause 2 of 3
The app client was deleted
1Check
Deleting an app client blocks every app that still uses its ID. A config that still holds the old ID keeps failing until you point it at a client that exists.
aws cognito-idp list-user-pool-clients --user-pool-id us-west-2_EXAMPLE --region us-west-22Fix
Use the ID of the replacement client if one exists. If none exists, create a new app client and put its ID into the app. A client's secret setting cannot be changed after creation, so create the new client with a secret only if the app sends SECRET_HASH.
aws cognito-idp create-user-pool-client --user-pool-id us-west-2_EXAMPLE --client-name my-web-app --region us-west-23Verify
The new ClientId appears in the list, and the sign-in works with it.
aws cognito-idp list-user-pool-clients --user-pool-id us-west-2_EXAMPLE --region us-west-2Confirmed by docs.aws.amazon.com
Cause 3 of 3
The app calls a different Region than the one holding the pool
1Check
User pools are created per Region, and each Region has its own endpoint (cognito-idp.us-west-2.amazonaws.com for us-west-2). The SDK for JavaScript does not pick a Region by itself, so a missing or wrong AWS_REGION, or a region value copied from another environment, sends the call to a Region that does not hold the client.
echo "AWS_REGION=$AWS_REGION"
grep -rn "region" src/ .env* 2>/dev/null2Fix
Set the Region of the pool for the Cognito client: in the client constructor option region, in the AWS_REGION environment variable, or in the shared config file. A Region passed to the constructor wins over the other two.
export AWS_REGION=us-west-2
node server.js3Verify
Run the failing call again. The same ClientId that was rejected now returns the client or signs the user in.
aws cognito-idp describe-user-pool-client --user-pool-id us-west-2_EXAMPLE --client-id 1example23456789 --region us-west-2Confirmed by docs.aws.amazon.com
How do I stop it coming back?
- Keep the user pool ID, the app client ID and the Region together in one config block per environment, so they cannot be mixed between staging and production.
- Read the app client ID from the pool (list-user-pool-clients) in your deploy script instead of pasting it by hand.
- Before deleting an app client, search every app and config for its ID.
- Set the Region explicitly in the client constructor instead of relying on the machine's environment.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
Related fixes
Security
Amazon Cognito /oauth2/token returns unauthorized_client
{"error":"unauthorized_client","error_description":"invalid_redirect"}
Cognito returns unauthorized_client from /oauth2/token when the app client is not allowed to use the grant you asked for, or when the redirect_uri in the token request differs from the one used at /oauth2/authorize.
3 causes, each with a fixBack end
The AWS SDK in Node.js cannot find any credentials
Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
The AWS SDK walks a fixed credential chain: code, environment variables, the shared files in ~/.aws, then role sources such as ECS or EC2.
3 causes, each with a fixBack end
AWS SDK for JavaScript v3 cannot find credentials, even for DynamoDB Local
A DynamoDB client pointed at http://localhost:8000 fails with the same message
The SDK walked its default credential provider chain and found nothing.
3 causes, each with a fixBack end
AWS SDK says the security token included in the request is invalid
The security token included in the request is invalid
The call reached AWS but the credentials it carried were refused.
3 causes, each with a fixBack end
Node.js S3 client cannot resolve my-bucket.localhost on LocalStack
Error: getaddrinfo ENOTFOUND bucketname.localhost
The SDK puts the bucket name in the hostname (virtual-hosted style), so it looks up my-bucket.localhost, which does not resolve.
3 causes, each with a fixBack end
S3 says Access Denied when my Node.js code reads or writes an object
Access Denied
S3 answers AccessDenied when no policy allows the exact action on the exact resource, when something denies it, or when the SDK signs with a different identity than you think.
5 causes, each with a fix