Git

Git "Fatal: Unable to Access: Could Not Resolve Host"

"Could not resolve host" is a DNS resolution failure — Git (via the underlying network library it uses) couldn't translate the hostname in your remote URL into an IP address at all, which points to either a genuine network/DNS problem or a typo in the remote URL itself, not an authentication or permissions issue.

The Problem

A Git operation involving a remote — clone, fetch, pull, push — fails immediately with:

fatal: unable to access 'https://github.com/user/repo.git/': Could not resolve host: github.com

This happens before any authentication step, distinguishing it from permission-related errors that occur after a successful connection.

Why It Happens

Since this is specifically a hostname resolution failure, the cause is almost always one of these:

  • Genuine lack of network connectivity — no internet connection at all, or a connection that's up but not actually able to reach external DNS servers
  • A typo in the remote URL, referencing a hostname that doesn't exist at all (a common copy-paste error, or an outdated URL from a repository that moved or was renamed)
  • DNS server configuration issues on the local machine or network specifically, where other network activity works but DNS resolution for this or all hostnames fails
  • A corporate or restrictive network firewall/proxy blocking DNS resolution for the specific domain, common on corporate VPNs or restrictive network environments that only allow access to an approved list of domains

The Fix

First, confirm basic network connectivity works at all, independent of Git:

ping github.com
curl -I https://github.com

If these also fail, the problem is confirmed to be network/DNS-level, not specific to Git — troubleshooting your general internet connection or DNS configuration is the actual next step, not anything Git-specific.

If general internet access works but this specific hostname doesn't resolve, test DNS resolution directly, isolating it from any application-level behavior:

nslookup github.com
dig github.com

Confirm the remote URL configured for your repository is actually correct, without any typo:

git remote -v

Compare this output character-for-character against the actual, current URL for the repository — a repository that was renamed, moved to a different hosting service, or has a URL with a small typo introduced when it was originally added produces exactly this error, since the hostname itself genuinely can't be resolved if it's wrong.

If you're on a restrictive network (corporate VPN, certain public Wi-Fi networks) that requires a proxy for external access, confirm Git is configured to use it, since Git doesn't automatically inherit system-wide proxy settings in every environment:

git config --global http.proxy http://proxyserver:port
git config --global https.proxy http://proxyserver:port

If you're unsure whether a proxy is required, check with your network administrator or compare behavior between the restrictive network and a different one (like a mobile hotspot) — if the same Git command works fine on a different network, the current network's proxy or firewall configuration is very likely the actual cause.

If DNS resolution is inconsistent or unreliable more generally on your machine, try explicitly setting a public DNS server (like Google's 8.8.8.8 or Cloudflare's 1.1.1.1) to rule out a problem with your current DNS provider specifically:

# Linux - temporarily test with a different resolver
sudo systemd-resolve --set-dns=8.8.8.8 --interface=eth0

Still Not Working?

If DNS resolution works fine for other domains but consistently fails specifically for the Git hosting service's domain, check whether that specific domain is being deliberately blocked by network-level content filtering or a corporate security policy — this is a common and often overlooked cause in managed corporate environments, where general internet access works normally but specific developer tool domains (GitHub, GitLab, npm registries, etc.) are intentionally restricted, requiring IT department involvement to resolve rather than any client-side configuration change.