The config profile (my-profile) could not be found
Fixes the AWS CLI 'The config profile could not be found' error. Use when aws rejects a --profile name or AWS_PROFILE value. Covers the missing [profile ] prefix in ~/.aws/config, typos, and the empty-string AWS_PROFILE trap. Not for credential errors.
The profile name does not match anything in your config. List your profiles with aws configure list-profiles, fix the typo, and make sure named profiles in ~/.aws/config use the [profile my-profile] header (only [default] goes bare). If AWS_PROFILE is set to an empty string, unset it entirely.
The config profile (my-profile) could not be foundFix
List the profiles the CLI actually sees:
aws configure list-profilesExpected: the profile name you want appears exactly, character for character.
If it is missing, check
~/.aws/config. Named profiles need the prefix:[profile my-profile] region = us-east-1Only
[default]goes without theprofileprefix. Fix the header, save, retry.- Check the right file: SSO,
role_arn, andsource_profilesettings belong in~/.aws/config; static IAM keys belong in~/.aws/credentials. A profile split across the wrong files will not resolve. If the error shows empty parentheses -
The config profile () could not be found- yourAWS_PROFILEis set to an empty string, which counts as a profile name. Fix it:unset AWS_PROFILEExpected:
aws sts get-caller-identityfalls back to the default profile and works.
When this applies
- Any
awscommand fails withThe config profile (name) could not be found, including the empty-parens variant. - You just edited
~/.aws/configor setAWS_PROFILEin a new shell.
When it does NOT apply
Unable to locate credentials: the profile resolves but has no credentials.ExpiredToken/InvalidClientTokenId: the profile resolves but the credentials are bad.
Compatibility
- AWS CLI v1 and v2. The
[profile name]header rule applies to~/.aws/configin both.
Why it happens
The CLI looks up the profile name in ~/.aws/config (and ~/.aws/credentials for keys). A typo, a missing profile prefix in the section header, or an AWS_PROFILE value that does not exist anywhere means the lookup finds nothing. The empty-string case is sneaky: export AWS_PROFILE="" sets a real (empty) name instead of clearing the variable.
Edge cases
AWS_CONFIG_FILE/AWS_SHARED_CREDENTIALS_FILEenv vars can point the CLI at different files than the ones you edited. Check them withenv | grep AWS_.- Profile names are case-sensitive.
- On Windows, the files live under
%UserProfile%\.aws.