brew updateを実行すると、Connection refusedと表示され失敗する

brew updateを実行すると、以下のエラーが表示され落ちてしまった。

$ brew update
fatal: unable to connect to :
[0: ::1]: errno=Connection refused
[1: 127.0.0.1]: errno=Connection refused

Error: Fetching /usr/local/Homebrew failed!

原因はSSHのリモートURLでgitに接続するようにしていたから。 GithubのリモートURLについてはリモートの URL の変更 - GitHub Docs参照。

.gitconfigに以下の2つが定義してあって、このうち[url "git://"]insteadOf = https:/の2行を削除したらbrew updateできた。

[url "https://"]
   insteadOf = git://
[url "git://"]
   insteadOf = https:/

brew updateで落ちたとき、なかなか解決策が見つからず一度homebrewをアンインストールして再インストールしようとした。 すると、再インストール時も以下のエラーで落ちてしまっていた。

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Password:
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew

Press RETURN to continue or any other key to abort
==> Downloading and installing Homebrew...
fatal: unable to connect to :
[0: ::1]: errno=Connection refused
[1: 127.0.0.1]: errno=Connection refused

Failed during: git fetch origin --force

ただ、再インストール時はbrew updateのときと違って、Failed during: git fetch origin --forceとログに書かれており、git fetchで失敗していると書かれていたため、これがSSHが原因であることの特定に繋がった。 (ので、アンインストールは全くの無駄足ではない...はず)

その後brew updateも実行して無事成功することも確認できた。

.gitconfigの設定を戻すと再び発生するので、もっと良い解決策があれば知りたい...