Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

git clone from CodeCommit over HTTPS returns 403

Errorfatal: unable to access 'https://git-codecommit.us-east-1.amazonaws.com/v1/repos/my-repo/': The requested URL returned error: 403

Short 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.

  • Applies to Git 2.4x, AWS CLI 2, macOS 15, Windows 11, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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 credential
  2. 2Match what you see, then jump to its fix

    1. 1403 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. 2It worked, then returned 403 after a few minutes; credential.helper shows osxkeychainmacOS keychain holds an expired CodeCommit passwordFix
    3. 3403 on Windows with the AWS helper configured; Credential Manager has a CodeCommit entryGit Credential Manager on Windows intercepts the requestFix
    4. 4git config printed a usage message, or Git could not read a user nameThe helper line was written with the wrong quotesFix
    5. 5aws codecommit credential-helper $@ get: aws: command not foundGit cannot find the aws command (Windows)Fix

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: 403
  • aws 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 -v

2Fix

Set the CLI region to the region in the repository URL.

aws configure set region us-east-2

3Verify

Try the Git command again.

git ls-remote origin

Confirmed by docs.aws.amazon.com

Did this fix it?

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.helper

2Fix

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 = true

3Verify

Clone again. If the old item was saved, delete git-codecommit entries from Keychain Access first.

git ls-remote origin

Confirmed by docs.aws.amazon.com

Did this fix it?

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.helper

2Fix

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 = true

3Verify

Open a new terminal and run a Git command against the repo.

git ls-remote origin

Confirmed by docs.aws.amazon.com

Did this fix it?

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.helper

2Fix

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 true

3Verify

Read the setting back, then run the Git command.

git config --global --get credential.helper
git ls-remote origin

Confirmed by docs.aws.amazon.com

Did this fix it?

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 --version

2Fix

Point the helper at aws.cmd explicitly.

git config --global credential.helper "!aws.cmd codecommit credential-helper $@"
git config --global credential.UseHttpPath true

3Verify

Open a new terminal and run the Git command again.

git ls-remote origin

Confirmed by docs.aws.amazon.com

Did this fix it?

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:

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 fix

Servers

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 fix

Servers

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 fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.