fatal: unable to access 'https://github.com/...': Could not resolve host: github.com
What causes this
Git can’t reach the remote server. Your machine can’t resolve the hostname to an IP address, or the connection is being blocked. This is almost always a network issue, not a Git issue.
Common causes:
- No internet connection (Wi-Fi dropped, ethernet unplugged)
- DNS server is down or misconfigured
- Corporate proxy or VPN blocking the connection
- The remote URL in your repo is wrong
- GitHub/GitLab is actually down (rare but happens)
Fix 1: Check your internet connection
# Can you reach anything?
ping google.com
# Can you reach GitHub specifically?
ping github.com
# Try a direct HTTP request
curl -I https://github.com
If ping fails for everything, it’s your internet connection. If only GitHub fails, it might be DNS or a firewall.
Fix 2: Check the remote URL
Maybe the URL is just wrong:
git remote -v
If it shows the wrong URL:
git remote set-url origin https://github.com/username/repo.git
Common mistakes: typos in the username, .git missing at the end, or using an old URL after a repo was renamed.
Fix 3: Flush your DNS cache
Your machine might have a stale DNS entry:
# macOS
sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder
# Linux (systemd)
sudo systemd-resolve --flush-caches
# Windows
ipconfig /flushdns
Then try the git command again.
Fix 4: Try a different DNS server
Your ISP’s DNS might be having issues. Switch to Google or Cloudflare DNS:
# Test with Google DNS
nslookup github.com 8.8.8.8
If that works, change your DNS settings to use 8.8.8.8 (Google) or 1.1.1.1 (Cloudflare).
Fix 5: Corporate proxy or VPN
If you’re behind a corporate proxy:
# Set the proxy for Git
git config --global http.proxy http://proxy.company.com:8080
git config --global https.proxy http://proxy.company.com:8080
If a VPN is interfering, try disconnecting it temporarily. Some VPNs route DNS through their own servers which may not resolve all hosts.
To remove proxy settings later:
git config --global --unset http.proxy
git config --global --unset https.proxy
Fix 6: Switch to SSH
If HTTPS keeps failing, try SSH instead:
git remote set-url origin git@github.com:username/repo.git
This bypasses HTTP proxy issues entirely. You’ll need an SSH key set up with GitHub.
How to prevent it
- Use SSH instead of HTTPS for Git remotes — it’s more reliable behind firewalls
- If you’re on a corporate network, get the proxy settings from IT and configure Git once
- Keep your DNS settings pointing to a reliable provider (Cloudflare
1.1.1.1or Google8.8.8.8)