CloudConsole

Unable to parse config file: ~/.aws/config

Updated 16 November 2026 · How we write and check guides

Short answer

The AWS CLI reads ~/.aws/config and ~/.aws/credentials as INI files, and one of them contains something that isn't valid INI: text before the first [section], a byte-order mark from a Windows editor, a duplicated section, or shell syntax such as export lines pasted in by mistake. Parse the file with Python to get the exact line number, fix that line, and retry.

Usual culprits, in 5 steps: 1. Byte-order mark at the start (saved from Notepad or PowerShell); 2. Text or keys before the…
The diagnosis and fix steps from this page, in the order to try them; commands and details are below.

What it means

$ aws sso login --profile prod
Unable to parse config file: /home/alice/.aws/config

Every CLI command loads the config before doing anything else, so a broken file stops even aws configure and aws sso login. The path in the message tells you which file failed: config, credentials, or a custom file named by AWS_CONFIG_FILE or AWS_SHARED_CREDENTIALS_FILE. The CLI doesn't print the line number, so you need another way to find it.

Find the exact line

Python's INI parser is close to what the CLI uses and reports the line and reason:

python3 -c 'import configparser,os,sys
p=configparser.RawConfigParser()
p.read(os.path.expanduser(sys.argv[1]))
print("ok:", p.sections())' ~/.aws/config

Typical output for a broken file:

configparser.MissingSectionHeaderError: File contains no section headers.
file: '/home/alice/.aws/config', line: 1
'[default]\n'

That  is a UTF-8 byte-order mark. Check for one, and for Windows line endings, with:

head -c 3 ~/.aws/config | od -c
file ~/.aws/config

Usual culprits

ProblemFix
Byte-order mark at the start (saved from Notepad or PowerShell)sed -i '1s/^\xEF\xBB\xBF//' ~/.aws/config, or re-save as UTF-8 without BOM
Text or keys before the first [section]Move them under [default] or a profile
Same section header twice, e.g. two [profile prod]Merge them into one
Same key twice in one sectionKeep one
export AWS_ACCESS_KEY_ID=… lines pasted inUse aws_access_key_id = … under a section in the credentials file
Git merge markers (<<<<<<<) from a dotfiles repoResolve the conflict
AWS_CONFIG_FILE points at a JSON or YAML filePoint it at an INI file, or unset it

Fix safely

  1. Back up the file first: cp ~/.aws/config ~/.aws/config.bak.
  2. Correct the line Python reported, then re-run the check until it prints ok: and your section list.
  3. Run the CLI again:
    aws configure list-profiles
    aws sso login --profile prod
  4. If ~/.aws/credentials was the broken one, the same check works on that path.

Note the section naming rules while you're in there: profiles in config are written [profile prod] (except [default]), SSO sessions as [sso-session name], and in credentials just [prod]. Getting these wrong doesn't break parsing, but it does produce profile could not be found next.

Avoid it next time

Prefer aws configure set, aws configure sso and aws configure --profile over hand-editing; they write valid entries. If you keep ~/.aws/config in a dotfiles repository, keep credentials out of it and run the Python check in a pre-commit hook.

Questions

Why does aws sso login say unable to parse config file?

aws sso login has to read ~/.aws/config to find the profile's SSO settings, so any syntax error in that file blocks it. Fix the line the parser reports and try again.

Does the AWS CLI support comments in the config file?

Yes, full-line comments starting with # or ; are fine. Keep comments on their own lines rather than after a value.

Can I reset my AWS config file?

Move it aside (mv ~/.aws/config ~/.aws/config.old) and run aws configure or aws configure sso to create a fresh one, then copy over the profiles you need.

CloudConsole home screen showing what needs attention on a phone, for following up on Unable to parse config file away from…
When this happens away from your desk

A broken config file takes every CLI command down at once, which hurts most during an incident. CloudConsole, a phone app for AWS, is built to keep alarms and logs viewable on your phone while you repair your local setup.

Did it start after a deploy? What changed? on the app’s alarm screen lists the deploys and configuration changes from the hour before the alarm fired.

About the app → · Download on the App Store

Sources