curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused 然后呢?

Homebrew 安装时会经常遇到题目中的错误。

然后呢?

问题的主要原因是你无法链接到 raw.githubusercontent.com,解决这个问题有两个思路:

1 曲线操作 既然连不上,那就换国内镜像:

试下gitee上有人提供的国内镜像 HomebrewCN

/bin/zsh -c "$(curl -fsSL [https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh](https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh))"
2 正面硬刚 网上也有很多解决思路,这里我总结一下:

2.1 先排除是github连接的问题:获取脚本,直接从终端执行脚本。
参考:stack overflow

这里我已经把相关的脚本准备好:homebrewinstallHelp

你可以尝试:

1 shell脚本方式(如果权限不够,先执行chmod 755 brew_install.sh)
./brew_install.sh

2 ruby脚本方式
ruby brew_install.rb

2.2 添加IP映射,解决DNS污染
参考:hawtim/blog/issues/10

通过 ipaddress.com 查询目标地址的IP,然后配置本机HOSTS文件,将目标域名链接到正确的IP。

-macOS:HOSTS文件存放在 /etc/hosts
-Windows:HOSTS文件存放在 C:\Windows\System32\drivers\etc\hosts
推荐使用 SwitchHosts 管理HOSTS文件,如果直接修改请务必先备份

# 添加以下配置即可
# Host Homebrew
199.232.68.133 raw.githubusercontent.com
199.232.68.133 user-images.githubusercontent.com
199.232.68.133 avatars2.githubusercontent.com
199.232.68.133 avatars1.githubusercontent.com

上述操作完成后,无论你是什么方式安装,最终执行的命令都是:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

接下来就慢慢下载吧

ruby brew_install.rb

你可能感兴趣的:(curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused 然后呢?)