彻底解决【“curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused”】错误

用如下命令下载安装msf时,提示curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused

curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall && \
  chmod 755 msfinstall && \
  ./msfinstall

之前也遇到过类似的错误,用的解决方法是,fq工具打开全局模式,然后打开curl后面的地址(这里是:https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb),之后另存为文件,并依次执行后续命令。

上面是最简单便捷的方法,详细内容可以参考:Homebrew installation on Mac OS X Failed to connect to raw.githubusercontent.com port 443

update – 最终解决方案

最近再次遇到该问题,详细了解了下,发现是 github 的一些域名的 DNS 解析被污染,导致DNS 解析过程无法通过域名取得正确的IP地址。可以通过修改/etc/hosts文件可解决该问题。

具体而言:

  1. 打开 https://www.ipaddress.com/ 输入访问不了的域名,获得对应的IP。

  2. 使用vim /etc/hosts命令打开不能访问的机器的hosts文件,添加如下内容:

    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
    

    注:上面内容中199.232.68.133是raw.githubusercontent.com所在的服务器IP(通过 https://www.ipaddress.com/ 获知)。

  3. 保存该文件,再使用即可正常访问。

该方案主要参考:【hawtim-blog】

  • 32
    点赞
  • 71
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值