BugMedic

Git “Could not resolve host”: fix DNS before credentials

Treat this as a network and DNS problem, not an authentication problem.

By BugMedic editorial teamLast source review: 2026-09-27Windows, macOS, Linux

Git cannot resolve the remote's hostname, so this is a DNS or network issue rather than credentials. Verify name resolution, then check proxy, VPN, or captive-portal interference before touching the repository.

Try these fixes in order

01

Test name resolution for the host

Run nslookup github.com (or your host) to test name resolution directly. If it fails, the problem is DNS on this machine or network, not Git and not your credentials.

nslookup github.com
02

Rule out captive portals and VPN state

Check whether general internet access works and whether you are behind a captive portal or VPN that needs sign-in. Reconnect the VPN or complete the portal login, then retry the resolve.

03

Configure the proxy Git should use

If the network requires a proxy, configure it for Git with git config --global http.proxy <proxy-url> and https.proxy, matching what the browser or IT documentation uses. Remove stale proxy entries if you left the corporate network.

git config --global http.proxy <proxy-url>
04

Retry with the verified URL

Retry the original clone, fetch, or push with the exact URL copied from the hosting provider. If resolution works but the connection still fails, the next error message will point at TLS or authentication instead of DNS.

Interpret what you see

No git remote host resolves, and browsers also fail

What it suggests: Name resolution itself is broken on this machine or network, so no remote host will work.

Next check: Try nslookup or Getent on another well-known hostname to confirm the failure is general.

Browsers can reach the host but git cannot

What it suggests: DNS works generally but Git traffic is forced through a proxy that is not configured, or a VPN/captive portal intercepts it.

Next check: Check env | grep -i proxy and git config --global --get-regexp 'http.*proxy'; compare with the browser's proxy settings.

Other hosts resolve but this one does not

What it suggests: The hostname is fine but the specific URL is wrong, for example a typo in the host or an internal host that only resolves on a VPN.

Next check: Copy the URL from the hosting provider's clone button and confirm the VPN connection if it is an internal host.

Why this happens

  • Local DNS is misconfigured or blocked, so the hostname never resolves.
  • A corporate proxy or VPN is required but Git is not configured to use it, or a captive portal is intercepting traffic.

Still not working?

Do not disable sslVerify or switch to an untrusted mirror to work around a DNS failure; those change security properties without fixing name resolution. If only one hosting provider fails while others resolve, check that provider's status page before changing local configuration.

Official sources

These steps are based on the linked documentation and general diagnostics. BugMedic has not independently tested every product and system configuration. Review commands before running them.

Related Git guides