The 'fatal: repository not found' error occurs when Git cannot locate or access the specified remote repository. This typically happens due to an incorrect URL, insufficient permissions, missing authentication, or the repository being deleted or renamed.
This error indicates that Git could not find the repository at the specified URL. When you run a command like `git clone`, `git pull`, or `git push`, Git attempts to communicate with the remote server to access the repository. This error appears when the server responds that no repository exists at that location. There are several distinct scenarios that trigger this error: 1. **The repository genuinely does not exist** - The URL is incorrect, the repository was deleted, or it was renamed to a different path. 2. **The repository is private and you lack access** - For security reasons, GitHub and other hosting services return a "not found" error instead of "access denied" when you try to access a private repository without proper authentication or permissions. This prevents attackers from discovering which private repositories exist. 3. **Authentication issues** - Your credentials may be expired, incorrect, or not configured properly for the repository URL you're using (HTTPS vs SSH). This error is common when cloning repositories, pushing to remotes for the first time, or when working with repositories after account/permission changes.
First, double-check that the repository URL is spelled correctly and exists.
# Check your current remote URL
git remote -v
# You should see output like:
# origin https://github.com/username/repository.git (fetch)
# origin https://github.com/username/repository.git (push)Common URL mistakes to check:
- Username typos: github.com/usrname/repo vs github.com/username/repo
- Repository name typos: Repository names are case-sensitive on some platforms
- Wrong organization: Using personal namespace instead of organization name
- Missing .git suffix: Some operations require the .git extension
Visit the repository URL in your browser to confirm it exists. If you get a 404 page, the URL is wrong or the repository doesn't exist.
If the repository is private, you must have explicit access granted by the owner or organization.
To verify your access:
1. Log into the Git hosting service (GitHub, GitLab, Bitbucket, etc.)
2. Navigate to the repository URL directly
3. If you can see the repository, you have access; if you get a 404, you don't
For GitHub:
- Check if you're a collaborator on the repository
- If it's an organization repo, verify your team has access
- Ask the repository owner to add you as a collaborator
For organization repositories:
Some organizations restrict access to members only. Contact your organization administrator if you believe you should have access.
Ensure you're properly authenticated. The method depends on whether you're using HTTPS or SSH.
For HTTPS URLs:
# GitHub - Use a Personal Access Token (PAT)
# Passwords no longer work as of August 2021
# Set up credential caching (stores credentials temporarily)
git config --global credential.helper cache
# Or on macOS, use the keychain
git config --global credential.helper osxkeychain
# On Windows, use the credential manager
git config --global credential.helper wincred
# Try cloning - you'll be prompted for username and PAT
git clone https://github.com/username/repository.gitCreating a Personal Access Token on GitHub:
1. Go to GitHub Settings > Developer settings > Personal access tokens
2. Click "Generate new token (classic)"
3. Select the repo scope for full repository access
4. Copy the token and use it as your password when prompted
For SSH URLs:
# Check if you have an SSH key
ls -la ~/.ssh/id_rsa.pub # or id_ed25519.pub
# Test SSH connection to GitHub
ssh -T [email protected]
# Expected success message:
# "Hi username! You've successfully authenticated..."If SSH test fails, add your SSH key to your Git hosting account.
Old or incorrect cached credentials can cause authentication to silently fail, resulting in a "not found" error.
On macOS:
# Remove GitHub credentials from Keychain
# Open Keychain Access app and search for "github.com"
# Or use command line:
git credential-osxkeychain erase
host=github.com
protocol=https
# Press Enter twice
# Then try your git operation again - you'll be prompted for new credentialsOn Windows:
# Open Credential Manager from Control Panel
# Or use:
git credential-manager-core erase
host=github.com
protocol=https
# Press Enter twice
# Alternative: Uninstall and reinstall credential manager
git credential-manager-core uninstall
git credential-manager-core installOn Linux:
# If using credential cache
git credential-cache exit
# If credentials are stored in a file
# Check and edit ~/.git-credentials
# Remove the stored credential for the specific host
git credential reject
host=github.com
protocol=https
# Press Enter twiceIf authentication isn't working with one method, try switching to the other.
Switch from HTTPS to SSH:
# View current remote
git remote -v
# Change to SSH URL
git remote set-url origin [email protected]:username/repository.git
# Verify the change
git remote -vSwitch from SSH to HTTPS:
# Change to HTTPS URL
git remote set-url origin https://github.com/username/repository.git
# Verify the change
git remote -vURL formats for different services:
| Service | HTTPS | SSH |
|---------|-------|-----|
| GitHub | https://github.com/user/repo.git | [email protected]:user/repo.git |
| GitLab | https://gitlab.com/user/repo.git | [email protected]:user/repo.git |
| Bitbucket | https://bitbucket.org/user/repo.git | [email protected]:user/repo.git |
You might be authenticated with a different account than the one that has access.
Check your Git configuration:
# Check global user configuration
git config --global user.name
git config --global user.email
# Check local repository configuration
git config user.name
git config user.emailFor SSH, check which key is being used:
# List loaded SSH keys
ssh-add -l
# Test GitHub connection with verbose output
ssh -vT [email protected]If you have multiple GitHub accounts:
You may need to configure SSH to use different keys for different accounts. Create or edit ~/.ssh/config:
# Personal account
Host github.com-personal
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_personal
# Work account
Host github.com-work
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_workThen use the custom host in your remote URL:
git remote set-url origin [email protected]:company/repo.gitIf you have two-factor authentication enabled, you must use a Personal Access Token (PAT) or SSH key - regular passwords won't work.
For HTTPS with 2FA:
1. Generate a Personal Access Token (PAT) as described in Step 3
2. Use the PAT instead of your password when prompted
3. Consider using a credential helper to store the token
For SSH with 2FA:
SSH authentication with keys works normally with 2FA enabled. If you're not already using SSH, consider switching:
# Generate a new SSH key if needed
ssh-keygen -t ed25519 -C "[email protected]"
# Start the SSH agent
eval "$(ssh-agent -s)"
# Add your key to the agent
ssh-add ~/.ssh/id_ed25519
# Copy your public key
cat ~/.ssh/id_ed25519.pub
# Add this to your GitHub account under Settings > SSH keys### GitHub Returns 404 for Permission Issues
For security reasons, GitHub returns a "repository not found" error (HTTP 404) instead of "permission denied" (HTTP 403) when you try to access a private repository without proper credentials. This prevents attackers from discovering which private repositories exist. If you're certain the repository exists, focus on authentication issues.
### OAuth App Access Restrictions
If the repository belongs to a GitHub organization, access might be restricted by OAuth app policies. Organization owners can restrict which OAuth apps can access organization resources. Contact your organization administrator if you believe this applies to you.
### SSH Agent Forwarding
When working on remote servers, you may need SSH agent forwarding to access repositories:
# Connect with agent forwarding
ssh -A user@remote-server
# Verify agent is available
ssh-add -lAdd this to your local ~/.ssh/config:
Host remote-server
ForwardAgent yes### Git Credential Manager
For Windows and macOS, the Git Credential Manager (GCM) provides a more robust solution:
# Check if GCM is installed
git credential-manager-core --version
# Configure Git to use GCM
git config --global credential.helper manager-coreGCM handles OAuth flows, PATs, and multi-account scenarios automatically.
### Submodule Repository Not Found
If you're getting this error for submodules:
# Update submodule URLs in .gitmodules if they've changed
git submodule sync
# Then update submodules
git submodule update --init --recursive### CI/CD Pipeline Considerations
For automated environments:
- Use deploy keys (SSH keys with repository-specific access)
- Use machine users with appropriate access tokens
- Ensure secrets/tokens are properly configured in your CI/CD system
- Check that tokens haven't expired
# Test authentication in CI before clone
ssh -T [email protected] || echo "SSH auth failed"### Mirror and Fork Scenarios
If you forked a repository that was later deleted or made private:
- Your fork may lose access to the upstream repository
- Update your remote to point only to your fork
- Or re-fork from a public copy if available
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