How to fix fatal: unable to access 'https://github.com/': Could not resolve host: github.com in Git

GitBEGINNERMEDIUMUpdated Dec 6, 2025· 382 views

This DNS resolution error occurs when Git cannot translate a hostname like github.com into an IP address. The issue is typically caused by network connectivity problems, misconfigured DNS settings, proxy interference, or firewall blocks on DNS traffic.

Quick fix

Fixes fatal: unable to access 'https://github.com/': Could not resolve host: github.com

# Test if you can reach the internet at all (uses IP, no DNS needed)
ping -c 4 8.8.8.8
  1. Verify basic network connectivity
  2. Check and remove Git proxy settings
  3. Fix DNS configuration on Linux
  4. Fix WSL2 DNS resolution issues
git — error
# Test if you can reach the internet at all (uses IP, no DNS needed)
ping -c 4 8.8.8.8
fatal: unable to access 'https://github.com/': Could not resolve host: github.com

What this error means

The "fatal: unable to access - Could not resolve host" error indicates that Git's attempt to connect to a remote repository failed at the most fundamental network level: DNS resolution. Before Git can establish a connection to github.com (or any remote host), your system must first translate that hostname into an IP address using the Domain Name System (DNS). When this lookup fails, Git cannot even begin the actual clone, push, or pull operation. The error is not specific to Git itself - it reflects a broader networking issue on your system that would affect any application trying to reach that hostname. This error commonly appears in several scenarios: - **Intermittent network issues**: Temporary network outages or unstable WiFi connections - **Corporate networks**: Proxy servers or firewalls blocking DNS traffic - **VPN interference**: VPN clients that override DNS settings or create routing conflicts - **WSL environments**: Windows Subsystem for Linux DNS configuration problems - **Docker containers**: Missing or incorrect DNS configuration inside containers - **Misconfigured /etc/resolv.conf**: Missing or incorrect nameserver entries on Linux systems

Typical symptoms

  • Git clone, push, pull, or fetch commands fail with 'Could not resolve host'
  • Error occurs consistently for all remote Git operations
  • Other applications may also fail to connect to internet services
  • ping github.com fails with 'unknown host' or similar error
  • The error appears immediately without any timeout delay
  • WSL commands fail to resolve hostnames while Windows works fine

Common causes

  1. No active internet connection or network adapter is disconnected
  2. DNS server is unreachable or not responding
  3. Proxy settings in Git or environment variables are misconfigured
  4. VPN client is interfering with DNS resolution
  5. Firewall blocking DNS traffic on port 53
  6. /etc/resolv.conf is empty, corrupt, or points to a non-working nameserver
  7. Corporate proxy requires authentication
  8. WSL2 DNS auto-generation created invalid configuration
  9. Hosts file contains incorrect entry for the domain
  10. Router DNS is malfunctioning

How to fix "fatal: unable to access 'https://github.com/': Could not resolve host: github.com"

1Verify basic network connectivity

First, check if you have general internet connectivity and can resolve DNS:

Test internet connectivity:

bash
# Test if you can reach the internet at all (uses IP, no DNS needed)
ping -c 4 8.8.8.8

Test DNS resolution:

bash
# Test if DNS is working
host github.com
# or
nslookup github.com
# or
dig github.com

Test connectivity to GitHub:

bash
ping -c 4 github.com

If ping 8.8.8.8 works but host github.com fails, you have a DNS problem. If even ping 8.8.8.8 fails, your network connection is down.

2Check and remove Git proxy settings

Incorrect proxy configuration is a common cause of this error. Check and clear proxy settings:

View current proxy settings:

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

Remove proxy settings if they exist:

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

Also check for environment variables:

bash
env | grep -i proxy

If you see HTTP_PROXY, HTTPS_PROXY, or similar variables, unset them temporarily:

bash
unset HTTP_PROXY
unset HTTPS_PROXY
unset http_proxy
unset https_proxy

Then try your Git command again.

3Fix DNS configuration on Linux

On Linux, DNS settings are controlled by /etc/resolv.conf. Check and fix it:

View current DNS configuration:

bash
cat /etc/resolv.conf

You should see one or more nameserver entries. If the file is empty or contains only comments, add public DNS servers:

Add Google and Cloudflare DNS:

bash
# Backup the existing file
sudo cp /etc/resolv.conf /etc/resolv.conf.backup

# Add working nameservers
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf
echo "nameserver 1.1.1.1" | sudo tee -a /etc/resolv.conf

If using NetworkManager, restart the network:

bash
sudo systemctl restart NetworkManager
# or
sudo service network-manager restart

Note: On some systems (like Ubuntu with systemd-resolved), you may need to configure DNS through /etc/systemd/resolved.conf instead.

4Fix WSL2 DNS resolution issues

WSL2 has known DNS issues. The auto-generated resolv.conf often points to the wrong nameserver:

Step 1: Disable auto-generation of resolv.conf

Create or edit /etc/wsl.conf:

bash
sudo tee /etc/wsl.conf << EOF
[network]
generateResolvConf = false
EOF

Step 2: Shutdown WSL completely from Windows:

powershell
# Run in Windows PowerShell or CMD
wsl --shutdown

Step 3: Restart WSL and recreate resolv.conf:

bash
# Remove the old symlink
sudo rm /etc/resolv.conf

# Create a new file with working DNS
sudo tee /etc/resolv.conf << EOF
nameserver 8.8.8.8
nameserver 1.1.1.1
EOF

Step 4: Test:

bash
ping github.com
git clone https://github.com/octocat/Hello-World.git
5Check and configure firewall for DNS

DNS uses port 53 (both TCP and UDP). Ensure it's not blocked:

On Linux with ufw:

bash
# Check firewall status
sudo ufw status

# Ensure DNS is allowed (should be by default)
sudo ufw allow out 53

On Linux with firewalld:

bash
sudo firewall-cmd --list-all
sudo firewall-cmd --add-service=dns --permanent
sudo firewall-cmd --reload

On Windows:
1. Open Windows Firewall (search "firewall" in Start menu)
2. Click "Allow an app or feature through Windows Firewall"
3. Ensure your Git client (Git Bash, Git GUI) is allowed

Check if your network/VPN is blocking DNS:

bash
# Try using a specific DNS server directly
nslookup github.com 8.8.8.8

If this works but regular nslookup github.com fails, your network's default DNS is the problem.

6Disable or configure VPN

VPN clients often interfere with DNS resolution:

Temporary test - disconnect VPN:
1. Temporarily disconnect your VPN
2. Try the Git command again
3. If it works, your VPN is the cause

VPN DNS solutions:

- Use the VPN's DNS servers: Many VPNs require you to use their DNS for security. Check your VPN's documentation.

- Configure split DNS: Some VPN clients let you exclude certain domains from the VPN tunnel.

- Cisco AnyConnect specific fix:

bash
# Check if VPN is overriding DNS
cat /etc/resolv.conf
# If it shows VPN DNS, you may need to manually add public DNS

On Windows, check if VPN is modifying adapter settings:

powershell
# View DNS servers for all adapters
Get-DnsClientServerAddress
7Check the hosts file for bad entries

A bad entry in the hosts file can prevent DNS resolution:

On Linux/macOS:

bash
cat /etc/hosts | grep -i github

On Windows (run as Administrator):

powershell
Get-Content C:\Windows\System32\drivers\etc\hosts | Select-String github

If you see any entries for github.com, remove them (unless you specifically added them for a reason):

On Linux/macOS:

bash
sudo nano /etc/hosts
# Comment out or delete any github.com lines

On Windows:
1. Open Notepad as Administrator
2. Open C:\Windows\System32\drivers\etc\hosts
3. Remove or comment out any github.com entries
4. Save the file

8Reset network settings

Sometimes resetting the network stack resolves persistent DNS issues:

On Windows (run as Administrator):

powershell
# Reset TCP/IP stack
netsh int ip reset

# Reset Winsock
netsh winsock reset

# Flush DNS cache
ipconfig /flushdns

# Release and renew IP
ipconfig /release
ipconfig /renew

Restart your computer after running these commands.

On macOS:

bash
# Flush DNS cache
sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder

On Linux:

bash
# Flush DNS cache (systemd-resolved)
sudo systemd-resolve --flush-caches

# Or restart the network
sudo systemctl restart NetworkManager

Simple fixes to try:
- Toggle your WiFi off and on
- Disconnect and reconnect your Ethernet cable
- Restart your router/modem

9Use SSH instead of HTTPS

If HTTPS continues to have issues, switching to SSH may help as it uses a different network path:

Step 1: Generate an SSH key (if you don't have one):

bash
ssh-keygen -t ed25519 -C "your_email@example.com"

Step 2: Add the SSH key to your GitHub account:

bash
# Copy the public key
cat ~/.ssh/id_ed25519.pub

Go to GitHub Settings > SSH and GPG keys > New SSH key, and paste the key.

Step 3: Test SSH connectivity:

bash
ssh -T git@github.com

Step 4: Clone using SSH:

bash
git clone git@github.com:username/repository.git

Step 5: Change existing remotes from HTTPS to SSH:

bash
# View current remote
git remote -v

# Change from HTTPS to SSH
git remote set-url origin git@github.com:username/repository.git

Advanced notes

Understanding the DNS resolution process:

When you run git clone https://github.com/user/repo.git, your system must:
1. Parse the URL and extract the hostname (github.com)
2. Query a DNS server to translate github.com to an IP address
3. Establish a TCP connection to that IP address on port 443 (HTTPS)
4. Perform the Git protocol operations

The "Could not resolve host" error means step 2 failed. The DNS query either:
- Never reached a DNS server (network issue)
- Reached a DNS server that didn't respond (server issue)
- Returned no results (domain doesn't exist or is blocked)

Diagnosing DNS issues with verbose output:

bash
# See detailed DNS resolution
dig github.com +trace

# Check which DNS server is being used
dig github.com

# Test against a specific DNS server
dig @8.8.8.8 github.com
dig @1.1.1.1 github.com

Permanent DNS configuration on different systems:

Ubuntu/Debian with systemd-resolved:

bash
# Edit /etc/systemd/resolved.conf
[Resolve]
DNS=8.8.8.8 1.1.1.1
FallbackDNS=8.8.4.4 1.0.0.1

# Restart the service
sudo systemctl restart systemd-resolved

RHEL/CentOS with NetworkManager:

bash
# Edit the connection
nmcli con mod "Connection Name" ipv4.dns "8.8.8.8 1.1.1.1"
nmcli con up "Connection Name"

Docker containers with DNS issues:

If Git fails inside Docker containers but works on the host, add DNS to your container:

bash
docker run --dns 8.8.8.8 your-image

Or in docker-compose.yml:

yaml
services:
  app:
    dns:
      - 8.8.8.8
      - 1.1.1.1

Or configure Docker daemon-wide in /etc/docker/daemon.json:

json
{
  "dns": ["8.8.8.8", "1.1.1.1"]
}

Corporate network considerations:

In corporate environments, you may need to:
1. Use the company's internal DNS servers (ask IT)
2. Configure proxy settings for Git
3. Use SSH with a proxy (via ProxyCommand in ~/.ssh/config)
4. Request firewall exceptions for git operations

IPv6 considerations:

GitHub supports IPv6, but if your network has broken IPv6 connectivity, it can cause connection issues. Prefer IPv4:

bash
# Force Git to use IPv4
git config --global http.version HTTP/1.1
# Or set in environment
export GIT_CURL_VERBOSE=1

Frequently asked questions

What does "fatal: unable to access 'https://github.com/': Could not resolve host:" mean?
The "fatal: unable to access - Could not resolve host" error indicates that Git's attempt to connect to a remote repository failed at the most fundamental network level: DNS resolution. com (or any remote host), your system must first translate that hostname into an IP address using the Domain Name System (DNS). When this lookup fails, Git cannot even begin the actual clone, push, or pull operation.
How do I fix "fatal: unable to access 'https://github.com/': Could not resolve host:"?
This DNS resolution error occurs when Git cannot translate a hostname like github.com into an IP address. The issue is typically caused by network connectivity problems, misconfigured DNS settings, proxy interference, or firewall blocks on DNS traffic.
What causes "fatal: unable to access 'https://github.com/': Could not resolve host:"?
No active internet connection or network adapter is disconnected DNS server is unreachable or not responding Proxy settings in Git or environment variables are misconfigured
Is the "fatal: unable to access 'https://github.com/': Could not resolve host:" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading