git clone from CodeCommit over HTTPS returns 403
fatal: unable to access 'https://git-codecommit.us-east-1.amazonaws.com/v1/repos/my-repo/': The requested URL returned error: 403Short answer
A 403 from CodeCommit over HTTPS usually means Git sent the wrong credentials, not none. The usual causes are an AWS CLI region that differs from the repository's, a keychain or Windows credential manager holding an expired or incompatible login, or a malformed credential helper line in your Git config.
Fix it fast
1Find out which cause you have
List every credential helper Git has loaded and which file defines it. Two competing helpers is the most common finding.
git config -l --show-origin | grep credential2Match what you see, then jump to its fix
- 1
403 on a repo you can see in the console, and aws configure shows another regionThe AWS CLI region differs from the repository's regionFix - 2
It worked, then returned 403 after a few minutes; credential.helper shows osxkeychainmacOS keychain holds an expired CodeCommit passwordFix - 3
403 on Windows with the AWS helper configured; Credential Manager has a CodeCommit entryGit Credential Manager on Windows intercepts the requestFix - 4
git config printed a usage message, or Git could not read a user nameThe helper line was written with the wrong quotesFix - 5
aws codecommit credential-helper $@ get: aws: command not foundGit cannot find the aws command (Windows)Fix
- 1
What does the error look like?
fatal: unable to access 'https://git-codecommit.us-east-1.amazonaws.com/v1/repos/my-repo/': The requested URL returned error: 403aws codecommit credential-helper $@ get: aws: command not found
Cause 1 of 5
The AWS CLI region differs from the repository's region
1Check
The credential helper signs requests with the region the CLI is set to. A repo in another region fails. Compare the two.
aws configure get region
git remote -v2Fix
Set the CLI region to the region in the repository URL.
aws configure set region us-east-23Verify
Try the Git command again.
git ls-remote originConfirmed by docs.aws.amazon.com
Cause 2 of 5
macOS keychain holds an expired CodeCommit password
1Check
The helper generates a short-lived password, and Apple's keychain helper stores it. Once it expires, the stored copy is sent and refused.
git config --show-origin --get-all credential.helper2Fix
Put an empty helper line before the AWS helper so the keychain is skipped for CodeCommit.
[credential "https://git-codecommit.us-east-1.amazonaws.com"]
helper =
helper = !aws codecommit credential-helper $@
UseHttpPath = true3Verify
Clone again. If the old item was saved, delete git-codecommit entries from Keychain Access first.
git ls-remote originConfirmed by docs.aws.amazon.com
Cause 3 of 5
Git Credential Manager on Windows intercepts the request
1Check
Git for Windows installs Git Credential Manager by default, and it is not compatible with the AWS credential helper.
git config --show-origin --get-all credential.helper2Fix
Remove stored CodeCommit entries in Windows Credential Manager, then scope the AWS helper to CodeCommit hosts in .gitconfig.
[credential "https://git-codecommit.*.amazonaws.com"]
helper = !aws codecommit credential-helper $@
UseHttpPath = true3Verify
Open a new terminal and run a Git command against the repo.
git ls-remote originConfirmed by docs.aws.amazon.com
Cause 4 of 5
The helper line was written with the wrong quotes
1Check
Linux, macOS and Unix need single quotes around the helper value, Windows needs double quotes. The wrong kind breaks the line.
git config --global --get credential.helper2Fix
Write the command again with the quotes for your system.
# Linux, macOS
git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true3Verify
Read the setting back, then run the Git command.
git config --global --get credential.helper
git ls-remote originConfirmed by docs.aws.amazon.com
Cause 5 of 5
Git cannot find the aws command (Windows)
1Check
Some Windows installs of the AWS CLI only provide aws.cmd, which Git's helper call does not resolve. Check which one is on the path.
aws --version2Fix
Point the helper at aws.cmd explicitly.
git config --global credential.helper "!aws.cmd codecommit credential-helper $@"
git config --global credential.UseHttpPath true3Verify
Open a new terminal and run the Git command again.
git ls-remote originConfirmed by docs.aws.amazon.com
How do I stop it coming back?
- Scope the AWS helper to CodeCommit hosts so other Git hosts keep their own credential store.
- Where possible use git-remote-codecommit or SSH, which avoid cached temporary passwords.
- Keep the CLI region and repository region the same, or use one profile per region.
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:
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
- RaheebA consumer app shipped to both stores from one Flutter codebase on a .NET and Azure back end.
- Loade DriverThe driver side of a delivery platform: live jobs, routing and earnings, past 5K Google Play downloads.
Related fixes
Servers
Apache has a certificate, but https:// does not open
No line with :443 in the output of ss -ltnp
HTTPS needs four things at once: mod_ssl loaded, Apache listening on 443, a virtual host on 443 with SSLEngine on, and a firewall that lets 443 in.
4 causes, each with a fixServers
AWS CLI says you must specify a region
You must specify a region. You can also configure your region by running "aws configure".
The AWS CLI sends every request to one region and has none to use.
4 causes, each with a fixServers
sam local fails: Running AWS SAM projects locally requires Docker
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
sam local start-api and sam local invoke run your function inside a Docker container, so SAM stops if it cannot talk to Docker.
3 causes, each with a fixServers
EC2 Instance Connect from the browser will not open an SSH session
Host key validation failed for EC2 Instance Connect
Browser-based EC2 Instance Connect needs five things at once: a fresh host key in the AWS database, a current agent package, port 22 open to the EC2 Instance Connect prefix list, a public address with a route (or an Instance Connect Endpoint), and a browser that can reach the proxy on port 443.
5 causes, each with a fixServers
EC2 instance shows 'Instance reachability check failed' and will not answer
Out of memory: kill process
A failed instance reachability check means the operating system inside the instance is not responding, so the problem is yours to fix, not AWS hardware.
4 causes, each with a fixServers
ssh to an EC2 instance hangs and ends in Connection timed out
Network error: Connection timed out
A timeout means your packets never got an answer, so this is a network path problem, not a key problem.
4 causes, each with a fix