Authentication failed

Git AuthenticationHTTPS ErrorCommonLast updated: June 29, 2026Tested on:Git CLI v2.44GitHub APIJune 2026

Git failed to authenticate your credentials (username, password, or token) when accessing a remote repository over HTTPS.

Authentication failed Quick Fix⏱️ Est. Fix Time: 3 minutes

Usually happens because:

  • Using standard account password instead of personal access token (PAT)
  • Expired token scopes or invalid session tokens
  • Stale or incorrect credentials cached in OS Keychain Manager

🔍 Quick Checklist:

What is Authentication failed?

This error occurs when you attempt to perform a remote Git operation (like git clone, git pull, or git push) over HTTPS, but the remote hosting provider (GitHub, GitLab, Bitbucket) rejects your credentials. In recent years, major Git providers have deprecated password-based HTTPS authentication in favor of Personal Access Tokens (PATs) or SSH keys. If you use your account password rather than a token, or if your credentials manager has cached expired credentials, the operation will be rejected.

Common Causes

  • Deprecated password authentication: Attempting to authenticate using your standard Git account password instead of a Personal Access Token (PAT).
  • Expired Personal Access Token (PAT): The token used for HTTPS authentication has expired or lacks the necessary repository read/write scopes.
  • Stale cached credentials: Your OS credential manager (like Windows Credential Manager or macOS Keychain) is holding expired credentials for the Git remote host.
CauseFrequency
Password used instead of access token (PAT)⭐⭐⭐⭐⭐
Stale or expired cached credentials⭐⭐⭐⭐
Insufficient token permission scopes⭐⭐⭐

Common Mistakes

  • Typing your normal account password into the CLI prompt when pulling/pushing. You must paste your Personal Access Token (PAT) instead.
  • Updating your password on the web interface but forgetting to refresh the entry saved inside your local OS credential manager.

How to Fix

1Generate a Personal Access Token: Go to your Git hosting settings and generate a new PAT with 'repo' scope, then use it as your password.
2Update cached credentials: Clear or update the stored credentials inside your operating system's credential manager.
3Use Git Credential Manager: Enable helper utilities to automate authentication prompt updates.

Git Operations & Verification

Bypass credentials prompts entirely by embedding your Personal Access Token directly inside the remote URL path.

Updating URL with PAT Token Example
# Syntax:
# git remote set-url origin https://<your_token>@github.com/username/repo.git

$ git remote set-url origin https://ghp_MySecureTokenValueHere@github.com/myuser/my-repo.git
$ git push origin main
# Succeeds immediately without credential queries

Platform Specific Fixes

Clear stale credential helpers or use local memory caching on Linux hosts.

Linux Config
# Cache credentials in memory for 15 minutes
git config --global credential.helper cache

# Or store credentials permanently on disk (unencrypted)
git config --global credential.helper store

Best Practices

  • Always switch to SSH keys (which do not expire as frequently as HTTP tokens) for local developer environments.
  • Use developer CLI managers like `gh auth login` to keep sessions securely authenticated.

Frequently Asked Questions (FAQ)

Q: Why does Git reject my password?

GitHub and other major hosts disabled password authentication for Git CLI operations over HTTPS. You must generate and use a Personal Access Token (PAT) instead.

Q: How do I generate a Personal Access Token on GitHub?

Go to Settings -> Developer settings -> Personal access tokens -> Tokens (classic) -> Generate new token. Ensure you select the 'repo' scope.

Q: How do I configure Git to remember my token?

Enable a credential helper using 'git config --global credential.helper cache' or use the official Git Credential Manager.

Q: Can I switch to SSH instead?

Yes. You can switch remote URLs to SSH by running: 'git remote set-url origin git@github.com:user/repo.git'.

Still having this problem?

Didn't solve your problem?

SuggestRequest Error