I am trying to push my latest code changes to a remote repository, but I keep getting the "fatal: unable to access: Could not resolve host: github.com" error in my terminal. This happens every time I run a git clone or git pull command. I have an active internet connection, so I’m not sure if this is a DNS issue, a proxy setting problem on my local machine, or something wrong with my GitHub Desktop configuration. How can I troubleshoot and resolve this host resolution error on Windows 11 or Linux?
3 answers
This error almost always points to a DNS resolution failure on your local network or machine. Even if your browser works, the terminal environment might be using a different DNS configuration. A quick fix is to flush your DNS cache. On Windows, run ipconfig /flushdns in Command Prompt. On Linux, you might need to restart the systemd-resolved service. If that doesn't work, try manually setting your DNS to Google's Public DNS (8.8.8.8 and 8.8.4.4) in your network adapter settings. This bypasses unreliable ISP DNS servers that often struggle to resolve GitHub's global load balancers, ensuring your Git client can find the correct IP address for the GitHub servers.
Are you working behind a corporate firewall or using a VPN right now? Often, these "Could not resolve host" errors occur because the Git global config hasn't been told to use the specific proxy server required by your company's network—have you checked your .gitconfig file for any old or missing proxy entries?
Try checking your /etc/hosts file (on Linux/Mac) or C:\Windows\System32\drivers\etc\hosts (on Windows). Ensure there isn't a manual, incorrect entry for github.com blocking the real IP.
Great point, Linda! Sometimes developers add those entries for testing and forget to remove them. Cleaning that file is a standard step in software development troubleshooting.
Robert is spot on. If you are in a corporate environment, you likely need to run a command like git config --global http.proxy http://proxyuser:[email protected]:8080. However, if you are at home, the issue might actually be your firewall blocking the Git executable itself. Check if your antivirus or Windows Firewall has recently updated and is now preventing the Git Bash terminal from making external outbound connections on port 443. I’ve seen this happen after major OS updates where permissions get reset unexpectedly.