Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何解决类似 curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused 的问题 #10

Open
hawtim opened this issue May 20, 2020 · 138 comments

Comments

@hawtim
Copy link
Owner

hawtim commented May 20, 2020

背景

笔者最近发现 github 的用户头像和自己文章中的图片显示不出来了。然后今天发现安装 homeBrew 和 nvm 出现了标题的报错信息。

image

以上是安装 pnpm 的报错信息,可以发现,脚本需要到 raw.githubusercontent.com 上拉取代码。

网上搜索了一下,发现是 github 的一些域名的 DNS 解析被污染,导致DNS 解析过程无法通过域名取得正确的IP地址。

DNS 污染

DNS 污染,感兴趣的朋友可以去了解一下。

解决方案

打开 https://www.ipaddress.com/ 输入访问不了的域名

image

查询之后可以获得正确的 IP 地址

在本机的 host 文件中添加,建议使用 switchhosts 方便 host 管理

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

添加以上几条 host 配置,页面的图片展示就正常了,homebrew 也能装了,nvm 也行动灵活了。

@jaggerzhang
Copy link

这个方法有效 🐂🍺

@Vincentzzg
Copy link

Vincentzzg commented Jul 8, 2020

亲测有效👍👍
使用SwitchHosts配置host之后
截屏2020-07-08 下午12 58 02

一直失败的RVM安装可以正常安装了
截屏2020-07-08 下午12 58 24

@whale4u

This comment has been minimized.

@alvinooc

This comment has been minimized.

@wangxin05

This comment has been minimized.

@KittenYang

This comment has been minimized.

@taoeu

This comment has been minimized.

@Fun005

This comment has been minimized.

@KDylan

This comment has been minimized.

@vitrum

This comment has been minimized.

@hawtim hawtim pinned this issue Jul 16, 2020
@Soulmate7

This comment has been minimized.

@wq1308786830

This comment has been minimized.

@Esmio

This comment has been minimized.

@xcdsycn

This comment has been minimized.

@AlbertSaiS

This comment has been minimized.

@0ck0

This comment has been minimized.

@Ninshar

This comment has been minimized.

@stayfoo

This comment has been minimized.

@pengqinppp

This comment has been minimized.

@karlinglee93

This comment has been minimized.

@ee-lynn

This comment has been minimized.

@lidapengpeng

This comment has been minimized.

@Dell-Z

This comment has been minimized.

@classliu

This comment has been minimized.

@zguiyang

This comment has been minimized.

@lzyzsd

This comment has been minimized.

@randomlwh

This comment has been minimized.

@laogui

This comment has been minimized.

@LittleCo
Copy link

LittleCo commented Nov 7, 2021

我通过修改 DNS 为 8.8.8.8 解决了这个问题。

@mqliutie
Copy link

果然切换了host可以了

@hustnzj

This comment was marked as duplicate.

@LorryIsLuRui

This comment was marked as duplicate.

@ypdaic
Copy link

ypdaic commented Dec 29, 2021

185.199.108.133 raw.githubusercontent.com
185.199.109.133 raw.githubusercontent.com
185.199.110.133 raw.githubusercontent.com
185.199.111.133 raw.githubusercontent.com

亲测有效

@hawtim

This comment was marked as duplicate.

@mogonow

This comment was marked as duplicate.

@Dsivs

This comment was marked as duplicate.

@gy1001

This comment was marked as duplicate.

@Jf710001011
Copy link

LittleCo

使用虚拟机 是在虚拟机里面改吗

@baozoudashijian

This comment was marked as duplicate.

@youlookwhat

This comment was marked as duplicate.

@geng130127

This comment was marked as duplicate.

@white-than-wood
Copy link

@geng130127 用国内镜像

@ppcode2022

This comment was marked as duplicate.

@RussellCao824

This comment was marked as duplicate.

@ZexiFangkong
Copy link

换了台新电脑, 居家办公, 频繁碰到这个问题, 亲测有效!

@HTH24
Copy link

HTH24 commented Dec 5, 2022

修改DNS地址为8.8.8.8有效

@huangminjianxx
Copy link

如果是mac,配置了host文件后,下载速度会出现为0的情况,需要先执行xcode-select --install命令,再执行curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash

@hawtim hawtim added the hosts label Mar 10, 2023
@JasonLou99
Copy link

我用ubuntu虚拟机,宿主机开了clash,虚拟机curl不能访问githubusercontent,但是虚拟机浏览器能访问,这个怎么解决?

@Yukey1874
Copy link

感谢大佬。Mac用switchhosts无法写入host,可以参考这篇
https://blog.csdn.net/Quasimodo19/article/details/114579541

@yuuuuuuan
Copy link

这是什么导致的呢?墙?

@LiuLiu-55
Copy link

这个方法有效

@FreezingM
Copy link

FreezingM commented Mar 13, 2024

@LittleCo
改了hosts文件后还是不行,但是听了这位的建议后成功了,感谢

我通过修改 DNS 为 8.8.8.8 解决了这个问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests