Software Development

How to fix the "Could not resolve host: github.com" error during Git operations?

JA Asked by James Miller · 14-11-2023
0 upvotes 13,601 views 0 comments
The question

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

0
MA
Answered on 17-11-2023

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. 

0
R
Answered on 19-11-2023

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?

DA 21-11-2023

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.

0
LI
Answered on 23-11-2023

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. 

JA 24-11-2023

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.

Share your thoughts

Your email address will not be published. Required fields are marked (*)

Professional Counselling Session

Still have questions?
Schedule a free counselling session

Our experts are ready to help you with any questions about courses, admissions, or career paths. Get personalized guidance from industry professionals.

Request a Call Back

Search Online

We Accept

We Accept

Follow Us

"PMI®", "PMBOK®", "PMP®", "CAPM®" and "PMI-ACP®" are registered marks of the Project Management Institute, Inc. | "CSM", "CST" are Registered Trade Marks of The Scrum Alliance, USA. | COBIT® is a trademark of ISACA® registered in the United States and other countries.

World globe icon Country: India

Book Free Session