# The config profile (name) could not be found

AWS error fixes · Updated 16 November 2026

**Short answer:** The CLI was told to use a named profile, through --profile or the AWS_PROFILE variable, and no section with that name exists in the config or credentials files it read. Most often AWS_PROFILE still points to a profile you renamed or deleted, or the section header is written the wrong way for its file: [profile prod] in ~/.aws/config, but plain [prod] in ~/.aws/credentials.

## What the CLI is looking for

```
$ aws sso login
The config profile (prod) could not be found
```

The name in brackets is the profile the CLI tried to load. It searches two files, and their header syntax differs:

| File | Named profile header | Default profile |
|---|---|---|
| `~/.aws/config` | `[profile prod]` | `[default]` |
| `~/.aws/credentials` | `[prod]` | `[default]` |

A section named `[prod]` in `config`, or `[profile prod]` in `credentials`, is not recognised as profile `prod`. Names are also case-sensitive: `Prod` and `prod` are different profiles.

## Causes, most likely first

1. **A stale `AWS_PROFILE`**. It's set in a shell profile, a `.envrc` or a CI variable and names a profile that no longer exists. Because it applies to every command, even `aws configure list` fails, which makes it look like the CLI is broken.
2. **Wrong header style**, as in the table above. Common after hand-copying a snippet meant for the other file.
3. **A different config file is being read**: `AWS_CONFIG_FILE` or `AWS_SHARED_CREDENTIALS_FILE` points elsewhere, or you're running as another user (`sudo`, a CI agent, a container) with its own home directory.
4. **A typo or case mismatch** between the command and the file.
5. **The profile was never created on this machine.** SSO profiles made with `aws configure sso` on your laptop don't exist on a build server or a teammate's machine.

## Fix it

1. See what the CLI thinks is selected and what exists:

   ```
   echo "AWS_PROFILE=$AWS_PROFILE AWS_CONFIG_FILE=$AWS_CONFIG_FILE"
   unset AWS_PROFILE
   aws configure list-profiles
   ```

2. If the profile isn't listed, look at the raw headers:

   ```
   grep -n '^\[' ~/.aws/config ~/.aws/credentials
   ```

   Correct the header style, or create the profile properly:

   ```
   aws configure sso --profile prod      # IAM Identity Center
   aws configure --profile prod          # access keys
   ```

3. Run the command again with the profile named explicitly:

   ```
   aws sso login --profile prod
   aws sts get-caller-identity --profile prod
   ```

4. Remove the stale `export AWS_PROFILE=…` from `~/.bashrc`, `~/.zshrc` or your CI settings if that was the cause.

## Tools beyond the CLI

SDKs and tools such as Terraform read the same files and the same variable, so a bad `AWS_PROFILE` breaks them all; the Python SDK reports it as `ProfileNotFound`. In Docker, mount the whole `~/.aws` directory to the container user's home (often `/root/.aws`) and pass `-e AWS_PROFILE=prod`. In VS Code dev containers and similar setups, check which user the terminal runs as before assuming the mount is correct.

## Questions

### Why does aws sso login say the config profile could not be found?

aws sso login uses AWS_PROFILE or the default profile when you don't pass --profile. If AWS_PROFILE names a profile that doesn't exist, or the SSO profile header isn't [profile name], it fails with this error.

### How do I list my AWS CLI profiles?

Run aws configure list-profiles. It prints every profile found in both the config and credentials files.

### Should I put profiles in config or credentials?

Settings such as region, SSO and role_arn belong in ~/.aws/config under [profile name]. Long-term access keys go in ~/.aws/credentials under [name]. Either file can define a profile, but the header styles differ.

## When this happens away from your desk

A profile mix-up usually just costs you a few minutes, but during an incident those minutes count. CloudConsole, a phone app for AWS, is built to keep alarms and logs readable on your phone while you get your terminal back in order.

[About the CloudConsole app](https://cloudconsole.dev/aws-console-app) · [Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710)

## Sources

- [Configuration and credential file settings in the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html)
- [Environment variables to configure the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html)

## Related

- [aws configure list-profiles](https://cloudconsole.dev/cli/configure-list-profiles)
- [How to switch between AWS profiles](https://cloudconsole.dev/how-to/switch-between-aws-profiles)
- [Unable to parse config file: ~/.aws/config](https://cloudconsole.dev/errors/unable-to-parse-config-file)
- [Error loading SSO Token: Token for <profile> does not exist](https://cloudconsole.dev/errors/error-loading-sso-token)
- [aws configure sso](https://cloudconsole.dev/cli/configure-sso)
- [Unable to locate credentials](https://cloudconsole.dev/errors/unable-to-locate-credentials)

---

Source: https://cloudconsole.dev/errors/config-profile-could-not-be-found

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
