How to Fix “fatal: unable to access : The requested URL returned error: 403” in Git

If youโ€™ve ever tried pushing or pulling code from a Git repository and hit the dreaded error fatal: unable to access : The requested URL returned error: 403, youโ€™re not alone. Itโ€™s one of those frustrating roadblocks that can stop you in your tracksโ€”especially if youโ€™re new to Git or working on a deadline. But donโ€™t worry! This guide will walk you through what this error means, why it happens, and how to fix it step-by-step in plain, easy-to-understand language.

By the end of this article, youโ€™ll not only solve the problem but also feel confident handling similar Git hiccups in the future. Whether youโ€™re a beginner or a seasoned coder, letโ€™s dive in and get that 403 error sorted out together!


What Does the “403” Error Mean?

Before we fix it, letโ€™s break down whatโ€™s happening. The error looks something like this:

fatal: unable to access 'https://github.com/username/repo.git/': The requested URL returned error: 403

In simple terms:

  • “fatal”: Gitโ€™s way of saying, โ€œI tried, but I canโ€™t do this.โ€
  • “unable to access ‘xxx'”: Git canโ€™t connect to the repository (the โ€œxxxโ€ is the URL youโ€™re trying to reach).
  • “403”: This is an HTTP status code that means โ€œForbidden.โ€ The server understands your request, but itโ€™s saying, โ€œNope, you donโ€™t have permission.โ€

Think of it like trying to enter a private club without the right passโ€”youโ€™re at the door, but they wonโ€™t let you in. So, why is Git rejecting you? Letโ€™s find out.


Why Youโ€™re Seeing the 403 Error in Git

There are a few common culprits behind this error. Knowing the โ€œwhyโ€ helps you pick the right fix. Here are the top reasons as of 2025:

1. Wrong or Expired Credentials

Git needs your permission to access a repository, usually through a username/password or a token. If your credentials are incorrect or outdated, youโ€™ll get a 403.

2. Permission Issues

You might not have the right access level for the repository. For example, if itโ€™s a private repo and youโ€™re not a collaborator, Git will block you.

3. Token Authentication Changes

Since GitHub dropped password support for HTTPS in 2021, you need a Personal Access Token (PAT) or SSH key. Using an old method? Thatโ€™s a 403 waiting to happen.

4. Typo in the URL

A tiny mistake in the repository URLโ€”like a misspelled username or repo nameโ€”can trigger this error.

5. Two-Factor Authentication (2FA)**

If 2FA is enabled on your account (common in 2025 for security), you canโ€™t use a plain password. Git needs a token instead.

6. Cached Credentials

Your computer might be holding onto old, invalid login info, confusing Git.

Now that weโ€™ve got the โ€œwhyโ€ covered, letโ€™s roll up our sleeves and fix it!


How to Fix the Git 403 Error: Step-by-Step Solutions

Hereโ€™s a clear roadmap to solve the fatal: unable to access 403 error. Try these fixes in orderโ€”they start simple and get more technical.

Step 1: Double-Check the URL

Letโ€™s start with the easiest fix. Look at the URL in the error message (e.g., https://github.com/username/repo.git). Ask yourself:

  • Did I spell the username and repo name correctly?
  • Is this the right repository?

To test it:

  1. Copy the URL from the error.
  2. Paste it into your browser.
  3. If it loads the repo, the URL is fine. If not, fix the typo and try again with:
git remote set-url origin https://correct-url-here.git
git push

Step 2: Verify Your Permissions

If the URL is correct, the issue might be access rights. Hereโ€™s how to check:

  • Public Repo: Anyone can clone it, but pushing requires collaborator status.
  • Private Repo: You need explicit permission from the owner.

Fix:

  • Log into your Git hosting platform (e.g., GitHub, GitLab, Bitbucket).
  • Visit the repoโ€™s settings.
  • Check if your account is listed under collaborators.
  • If not, ask the owner to add you (e.g., on GitHub, theyโ€™d go to Settings > Collaborators).

Step 3: Update Your Authentication Method

In 2025, HTTPS Git operations rely on tokens, not passwords. If youโ€™re still using a passwordโ€”or an expired tokenโ€”youโ€™ll hit a 403.

Fix for GitHub (Personal Access Token)

  1. Generate a Token:
  • Go to GitHub.com > Settings > Developer settings > Personal access tokens > Tokens (classic).
  • Click โ€œGenerate new token.โ€
  • Select scopes: repo, workflow, and gist.
  • Copy the token (e.g., ghp_xxxxxxxxxxxxxxxx).
  1. Update Git:
    Run this command and enter your username and the token when prompted:
   git push

Or set it in the URL:

   git remote set-url origin https://username:token@github.com/username/repo.git
   git push

Fix for GitLab/Bitbucket

  • GitLab: Settings > Access Tokens > Create a PAT with api and read_repository scopes.
  • Bitbucket: Account > Personal access tokens > Create with โ€œRepositories: Write.โ€

Step 4: Clear Cached Credentials

Your computer might be using old credentials. Letโ€™s clear them out.

On Windows

  1. Open Credential Manager (search it in the Start menu).
  2. Go to โ€œWindows Credentials.โ€
  3. Find entries like git:https://github.com.
  4. Remove them.
  5. Try pushing againโ€”enter your new token when prompted.

On macOS

  1. Open Keychain Access (search via Spotlight).
  2. Search for โ€œgithub.โ€
  3. Delete any related entries.
  4. Retry your Git command.

On Linux

  1. Run:
   git credential-cache exit
  1. Or edit ~/.git-credentials and remove outdated lines.

Step 5: Switch to SSH Instead of HTTPS

If HTTPS keeps failing, SSH is a reliable alternative. Hereโ€™s how:

  1. Generate an SSH Key:
   ssh-keygen -t ed25519 -C "your-email@example.com"

Press Enter for defaults, then find your key in ~/.ssh/id_ed25519.pub.

  1. Add It to Your Hosting Platform:
  • GitHub: Settings > SSH and GPG keys > New SSH key.
  • Paste the key (copy it with cat ~/.ssh/id_ed25519.pub).
  1. Update Your Remote URL:
   git remote set-url origin git@github.com:username/repo.git
   git push
  1. Test It:
   ssh -T git@github.com

If you see โ€œHi username!โ€ youโ€™re good!


Step 6: Check for VPN or Network Issues

Sometimes, a 403 isnโ€™t your faultโ€”itโ€™s the network. If youโ€™re on a VPN or company Wi-Fi:

  • Try a Different Network: Switch to mobile data or another Wi-Fi.
  • Disable VPN: Some VPNs block Git servers.
  • Contact IT: If at work, your firewall might be the culprit.

Retry your command after switching networks.


Real-Life Example: Fixing the 403 Error

Letโ€™s walk through a quick scenario:

  • You: Trying to push to https://github.com/johndoe/myproject.git.
  • Error: fatal: unable to access... 403.
  1. Check the URLโ€”looks good.
  2. Log into GitHubโ€”youโ€™re a collaborator.
  3. Realize your old password isnโ€™t working (GitHub needs a token).
  4. Generate a PAT, update the remote URL:
   git remote set-url origin https://johndoe:ghp_xxxx@github.com/johndoe/myproject.git
  1. Push againโ€”success!

See? Itโ€™s a process, but it works.


Troubleshooting Tips

Still stuck? Try these:

  • Verbose Output: Run GIT_CURL_VERBOSE=1 git push to see detailed error info.
  • Check Token Scopes: Ensure your PAT has repo access.
  • Update Git: Old Git versions (pre-2.40) can glitch. Upgrade with git --version and your package manager.

Preventing the 403 Error in 2025

Hereโ€™s how to avoid this headache next time:

  • Use SSH from the startโ€”itโ€™s more stable than HTTPS.
  • Save tokens securely with a credential manager (e.g., Gitโ€™s credential.helper).
  • Keep Git and your tools updatedโ€”2025โ€™s latest Git version is 2.44.

Final Thoughts

The fatal: unable to access : The requested URL returned error: 403 message might feel like a brick wall, but itโ€™s fixable. Whether itโ€™s a typo, a token issue, or permissions, youโ€™ve now got the tools to tackle it. Git is your friendโ€”donโ€™t let a 403 scare you off!

If you are still facing issue refer below resources:

Leave a Comment