This error appears when Git cannot access a remote repository due to authentication issues, missing permissions, or an incorrect URL. The fix typically involves verifying your credentials or requesting repository access.
This error occurs when Git cannot locate the remote repository at the specified URL. The message "fatal: repository not found" is somewhat misleading because it can appear not only when the repository truly doesn't exist, but also when you lack proper authentication or authorization to access it. GitHub, GitLab, and other hosting providers return this generic "not found" message for security reasons: they don't reveal whether a private repository exists if you don't have access to it. This means the same error can indicate a genuine typo in the URL, a deleted repository, or simply that your credentials are incorrect or expired. If you previously had access to a repository and suddenly receive this error, the most likely cause is an authentication problem—perhaps an expired Personal Access Token, recently enabled Two-Factor Authentication, or cached credentials that no longer work.
Open the repository URL in your browser to confirm it exists and you have access:
# Check your current remote URL
git remote -vIf the repository was renamed or transferred, update the URL:
git remote set-url origin https://github.com/correct-user/correct-repo.gitTest if you can authenticate with GitHub/GitLab:
For SSH:
ssh -T [email protected]
# Should respond: "Hi username! You've successfully authenticated"For HTTPS (GitHub CLI):
gh auth statusIf authentication failed, re-authenticate:
Using GitHub CLI (recommended):
gh auth loginClear cached credentials and try again:
*Windows (Credential Manager):*
1. Open Control Panel > Credential Manager
2. Remove entries for github.com or gitlab.com
*macOS (Keychain):*
git credential-osxkeychain erase
host=github.com
protocol=https
# Press Enter twice*Linux:*
git config --global --unset credential.helperGitHub no longer accepts passwords for Git operations. Create a PAT:
1. Go to GitHub Settings > Developer settings > Personal access tokens > Tokens (classic)
2. Click Generate new token
3. Select scopes: at minimum repo (full control of private repos)
4. Generate and copy the token
Use the token as your password when prompted:
git clone https://github.com/user/repo.git
# Username: your-username
# Password: paste-your-token-hereOr embed it in the URL (for scripts):
git clone https://[email protected]/user/repo.gitIf it's a private repository you don't own, request access:
1. Contact the repository owner or organization admin
2. Ask to be added as a Collaborator (for personal repos) or to the appropriate Team (for org repos)
3. Accept the invitation sent to your email
4. Try cloning again after access is granted
Sometimes switching protocols resolves authentication issues:
Switch to SSH:
git remote set-url origin [email protected]:user/repo.gitSwitch to HTTPS:
git remote set-url origin https://github.com/user/repo.gitIf using SSH, ensure your key is added:
# List SSH keys
ls -la ~/.ssh/
# Add key to ssh-agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519Why "repository not found" instead of "access denied"?
Git hosting services intentionally use vague "not found" errors for security. Revealing that a private repository exists (but you lack access) would leak information to potential attackers. This design choice, while secure, makes troubleshooting harder.
Organization-owned repositories and SAML SSO:
If your organization uses SAML Single Sign-On, your Personal Access Token must be explicitly authorized for SSO access. After creating a PAT, click "Configure SSO" next to the token and authorize it for your organization.
SSH keys and OAuth applications:
SSH keys generated by third-party Git clients (like GitKraken) may be tied to an OAuth application. These keys require explicit organization approval if you're accessing org-owned repositories. Consider generating a standard SSH key pair independently.
Enterprise Server vs GitHub.com:
Ensure you're using the correct host. GitHub Enterprise Server installations have different URLs (e.g., github.mycompany.com instead of github.com). Credentials don't transfer between instances.
Fine-grained PATs:
GitHub's newer fine-grained Personal Access Tokens require explicit repository permissions. If you created a fine-grained PAT, verify it grants access to the specific repository you're trying to reach.
kex_exchange_identification: Connection closed by remote host
Connection closed by remote host when connecting to Git server
fatal: unable to access: Proxy auto-configuration failed
How to fix 'Proxy auto-configuration failed' in Git
fatal: unable to access: Authentication failed (proxy requires basic auth)
How to fix 'Authentication failed (proxy requires basic auth)' in Git
fatal: unable to access: no_proxy configuration not working
How to fix 'no_proxy configuration not working' in Git
fatal: unable to read tree object in treeless clone
How to fix 'unable to read tree object in treeless clone' in Git