Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

github

I got a similar error, and it's caused by incorrect proxy setting. This command saved me:

git config --global --unset http.proxy

https version:

git config --global --unset https.proxy

do i need to configure proxy settings? because my office has got proxy servers.

Yes, you can do so by setting HTTP_PROXY, and HTTPS_PROXY environment variables.

See "Syncing with github":

set HTTPS_PROXY=http://<login_internet>:<password_internet>@aproxy:aport
set HTTP_PROXY=http://<login_internet>:<password_internet>@aproxy:aport
set NO_PROXY=localhost,my.company

(To avoid putting your credentials -- username/password -- in clear in the proxy URL, see below)

Note the NO_PROXY, to allow to access internal site to your company

You also can register that in your git config:

git config --global http.proxy http://<login_internet>:<password_internet>@aproxy:aport

But if you have incorrect proxy Git settings, remove them:

cd /path/to/repo
git config --unset http.proxy
git config --global --unset http.proxy
git config --system --unset http.proxy

git config --unset https.proxy
git config --global --unset https.proxy
git config --system --unset https.proxy

# double-check with:
git config -l --show-origin | grep -i proxy

No credentials needed: use genotrance/px.
If you are, as I am, in a company behind a NTLM proxy, all you need to do is:

  • unzip px-v0.4.0.zip anywhere you want
  • change the px.ini config file (put it in %USERPROFILE%), chaging the server line:
    [proxy]
    server = proxy.my.company:8080  <= use your company proxy:port
    listen = 127.0.0.1
    port = 3128
    
  • use HTTP(S) proxy variable without your credentials! (the px proxy will reuse the ones from the current Widows session, either through Microsoft SSPI or Microsoft Kerberos)

That will give you:

set HTTPS_PROXY=http://127.0.0.1:3128
set HTTP_PROXY=http://127.0.0.1:3128
set NO_PROXY=localhost,my.company

Spent a couple hours trying to fix this.

Re-connecting my wifi did the trick.


another possibility, I ran into this problem myself. But it was after I had installed a VPN (which was unrelated and running)

turning off the VPN, fixed the issue.

for the record, I was running "Viscosity" VPN on my MacBookPro


I've had the same issue after running out of disk space. Closing and reopening terminal fixed it one time. Restarting my Mac the next.

Some easy things to try before jumping to random commands:

  • restart terminal tab
  • restart terminal app
  • If disk is full (or close to it) free up some disk space then restart terminal app
  • restart machine/OS