Skip to content
fatal: could not read from remote repository

fatal: could not read from remote repository

DodaTech 3 min read

Git’s fatal: could not read from remote repository error means Git couldn’t connect to the remote server to fetch or push data, usually due to an authentication, network, or URL problem.

What It Means

Git attempts to establish a connection to the remote repository URL configured for your repo. If the connection fails at the transport layer — SSH handshake fails, HTTPS credentials are rejected, DNS lookup fails, or the server is unreachable — Git reports that it couldn’t read from the remote. The error is often accompanied by a more specific message like Permission denied (publickey) or Could not resolve host.

Why It Happens

  • SSH key isn’t configured or is incorrect for the remote host.
  • Remote URL is wrong (typo in the repo path or hostname).
  • Network issues: VPN not connected, corporate firewall blocking ports, or DNS resolution failure.
  • Repository doesn’t exist on the server (deleted, renamed, or private and you lack access).
  • HTTPS credentials expired or personal access token revoked.

How to Fix It

1. Test SSH authentication (for SSH remotes)

ssh -T git@github.com
ssh -T git@gitlab.com

If you see Permission denied, follow the SSH key setup guide.

2. Verify the remote URL

git remote -v

Check the URL for typos. If it’s wrong, update it:

# SSH format
git remote set-url origin git@github.com:user/repo.git

# HTTPS format
git remote set-url origin https://github.com/user/repo.git

3. Switch from SSH to HTTPS (or vice versa)

If SSH is blocked by your firewall, try HTTPS:

git remote set-url origin https://github.com/user/repo.git

Or if HTTPS isn’t working, try SSH:

git remote set-url origin git@github.com:user/repo.git

4. Test DNS and network connectivity

ping github.com
nslookup github.com

If ping fails, check your internet connection, VPN, or proxy settings.

5. Use a personal access token (for HTTPS)

GitHub deprecated password authentication over HTTPS. Use a personal access token:

git clone https://github.com/user/repo.git
# Enter username: your-username
# Enter password: your-personal-access-token

6. Check repository access

Open the URL in a browser. If you get a 404, the repo may be private (and you’re not a collaborator), renamed, or deleted.

What's the most common cause of this error?
The most common cause is an SSH key that hasn’t been added to the ssh-agent. Run ssh-add ~/.ssh/id_ed25519 to load your key, then test with ssh -T git@github.com. The second most common cause is an incorrect remote URL — always double-check with git remote -v.
Does a VPN cause this error?
Yes. Corporate VPNs often block SSH port 22 or intercept HTTPS traffic with self-signed certificates. If you’re on a VPN, try disconnecting temporarily, or switch to HTTPS with a personal access token. Some VPNs also override DNS, which can make github.com resolve to an internal IP.
Can the server-side cause this error?
Yes — if the repository is deleted, renamed, or its visibility changed from public to private, Git will report it can’t read from the remote. The server may also be down for maintenance. Check the repo URL in a browser to rule out server-side issues.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro