Git
GitHub
Troubleshooting
Network Error
Clone Repository

Git Could not resolve host github.com error while cloning remote repository in git

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

Could not resolve host: github.com is a DNS or network-resolution problem, not a Git authentication problem. Git is telling you that your machine could not turn github.com into an IP address, so the fix is usually in networking, DNS, proxy settings, or local configuration rather than in the repository itself.

Confirm It Is Really a Name-Resolution Failure

Start by checking whether the machine can resolve github.com outside Git.

bash
ping github.com
nslookup github.com
dig github.com

If those commands also fail, the problem is system-level DNS or network access. If they succeed while Git fails, the issue is more likely to be Git-specific proxy configuration or environment variables.

Check Basic Connectivity First

The simplest cause is still worth checking: no working internet connection.

bash
curl -I https://github.com

If curl cannot reach GitHub either, Git is not the unique problem. At that point you should look at Wi-Fi, VPN state, corporate network restrictions, or firewall behavior before changing Git settings.

Inspect Git Proxy Configuration

Git can have its own proxy settings that override general system behavior. These settings are a frequent source of confusion on work networks and after old proxy setups are forgotten.

bash
1git config --global --get http.proxy
2git config --global --get https.proxy
3git config --system --get http.proxy
4git config --system --get https.proxy

If a stale or incorrect proxy appears, remove it:

bash
git config --global --unset http.proxy
git config --global --unset https.proxy

A bad proxy entry can make Git fail even while the browser works.

Review Environment Variables Too

Shell environment variables can override or influence network behavior.

bash
env | grep -i proxy

If you see outdated HTTP_PROXY, HTTPS_PROXY, or related variables, they may be redirecting Git through a host that no longer exists. Unset them for the current shell and test again.

bash
1unset HTTP_PROXY
2unset HTTPS_PROXY
3unset http_proxy
4unset https_proxy

Try a Different DNS Resolver

If the machine is online but DNS resolution fails intermittently, switching to a known public DNS resolver can help identify the issue. The exact steps depend on the operating system, but the point is to rule out broken local or corporate DNS infrastructure.

Common test resolvers include:

  • '8.8.8.8'
  • '1.1.1.1'

This is a diagnostic step as much as a fix. If Git starts working after the DNS change, you have confirmed the root problem is resolution rather than Git itself.

Check the Remote URL Itself

Although the hostname error points to DNS, confirm that the remote really is github.com and not a typo.

bash
git remote -v

A misspelled host or malformed URL can produce the same resolution failure message.

For a fresh clone, verify the exact URL you are using:

bash
git clone https://github.com/owner/repo.git

VPNs, Firewalls, and Corporate Networks Can Interfere

On managed networks, GitHub access may be filtered or only reachable through approved proxies. VPN clients can also replace DNS settings and break resolution unexpectedly.

If the problem started immediately after connecting to a VPN, moving networks, or entering a corporate environment, that context matters. In those cases the correct fix may be network policy or approved proxy configuration, not random local edits.

Common Pitfalls

  • Treating the error as a Git credential issue instead of a DNS issue.
  • Fixing nothing because the browser works while Git is still bound to a stale proxy setting.
  • Forgetting to inspect shell proxy environment variables in addition to Git config.
  • Testing only Git and never checking system-level name resolution.
  • Assuming the remote URL is correct without actually verifying it.

Summary

  • 'Could not resolve host: github.com means name resolution failed before Git could even reach GitHub.'
  • Check system-level DNS and connectivity first with tools such as ping, nslookup, or curl.
  • Inspect Git proxy settings and shell proxy variables for stale configuration.
  • Verify the remote URL is correct.
  • If the problem is network- or VPN-related, the real fix may be outside Git itself.

Course illustration
Course illustration

All Rights Reserved.