Why does git fetch fail with “Could not resolve host: (nil)…” with https://github.com/mxcl/homebrew origin?

I was unable to install Homebrew (see my question on apple.stackexchange.com), so I looked at the https://raw.github.com/mxcl/homebrew/go Ruby script and tried the same commands it runs:

$ git init -q
$ git remote add origin https://github.com/mxcl/homebrew
$ git fetch origin master:refs/remotes/origin/master -n
error: Could not resolve host: (nil); nodename nor servname provided, or not known while accessing https://github.com/mxcl/homebrew/info/refs?service=git-upload-pack
fatal: HTTP request failed

Why am I getting this error?

Update: (in response to madhead’s answer)

I get the same problem when I use the URL with .git postfixed:

$ git init -q
$ git remote add origin https://github.com/mxcl/homebrew.git
$ git fetch origin master:refs/remotes/origin/master -n
error: Could not resolve host: (nil); nodename nor servname provided, or not known while accessing https://github.com/mxcl/homebrew.git/info/refs?service=git-upload-pack
fatal: HTTP request failed

Update #2:

I don’t think this was a proxy issue (as suggested in neil’s answer).

I tried this again and it worked!

$ git init -q
$ git remote add origin https://github.com/mxcl/homebrew
$ git fetch origin master:refs/remotes/origin/master -n
remote: Counting objects: 126721, done.
remote: Compressing objects: 100% (59085/59085), done.
remote: Total 126721 (delta 89963), reused 100145 (delta 66623)
Receiving objects: 100% (126721/126721), 19.68 MiB | 702 KiB/s, done.
Resolving deltas: 100% (89963/89963), done.
From https://github.com/mxcl/homebrew
 * [new branch]      master     -> origin/master

I looked in my ~/.gitconfig file and discovered I had already defined a proxy. I think that was already there when I had the problem, but to confirm I removed it and got a different error:

$ git fetch origin master:refs/remotes/origin/master -n
error: Failed connect to github.com:443; Connection refused while accessing https://github.com/mxcl/homebrew/info/refs?service=git-upload-pack
fatal: HTTP request failed

My theory is that github or homebrew had some kind of problem that they’ve since fixed.

  • Can I link git submodules with some kind of fallback URL? If SSH clone fails, git should be able to clone using https
  • How to disable SSH in GitBash and use HTTPS instead
  • Github HTTPS cloning via proxy
  • passing ciphers to libcurl through git?
  • Git over HTTPS can ls-list but cannot clone
  • How to install Sails js via npm through a firewall
  • GitLab SSL handshake error when performing a Git Pull/Clone Using TortoiseGit and Ansible
  • Git stopped working over SSL on Windows
  • 3 Solutions collect form web for “Why does git fetch fail with “Could not resolve host: (nil)…” with https://github.com/mxcl/homebrew origin?”

    For me this was related to a proxy issue. When I’m on VPN I need to add

    [http]
    proxy = http://proxy.example.com
    

    to my ~/.gitconfig, and if I’m not on the VPN, this proxy cannot be found.

    For those getting this error when NOT behind a proxy:

    error: Could not resolve host: (nil); nodename nor servname provided, or not known while accessing https://github.com/mxcl/homebrew/info/refs?service=git-upload-pack
    fatal: HTTP request failed
    

    the solution may be to clear the git proxy settings:

    $ git config --global --unset core.gitproxy
    

    You remote URL is incorrect, it should be https://github.com/mxcl/homebrew.git (.git postfixed) instead of https://github.com/mxcl/homebrew. You can copypaste URLs from Github UI to prevent such typos.

    Git Baby is a git and github fan, let's start git clone.