hawtim.github.io icon indicating copy to clipboard operation
hawtim.github.io copied to clipboard

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

Open hawtim opened this issue 4 years ago • 138 comments

背景

笔者最近发现 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 也行动灵活了。

hawtim avatar May 20 '20 10:05 hawtim

这个方法有效 🐂🍺

jaggerzhang avatar Jul 07 '20 11:07 jaggerzhang

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

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

Vincentzzg avatar Jul 08 '20 05:07 Vincentzzg

这个方法有效,前排支持!

whale4u avatar Jul 10 '20 02:07 whale4u

感谢感谢,亲测有效。

alvinooc avatar Jul 10 '20 15:07 alvinooc

感谢

wangxin05 avatar Jul 12 '20 09:07 wangxin05

有效!

KittenYang avatar Jul 12 '20 11:07 KittenYang

世界终于回归正常了,感谢!

taoeu avatar Jul 15 '20 01:07 taoeu

🐂🍺,亲测有效

Fun005 avatar Jul 15 '20 03:07 Fun005

perfect

KDylan avatar Jul 15 '20 07:07 KDylan

666 完美

vitrum avatar Jul 16 '20 05:07 vitrum

谢谢,亲测有效!

Soulmate7 avatar Jul 17 '20 03:07 Soulmate7

really help

wq1308786830 avatar Jul 17 '20 05:07 wq1308786830

谢谢,Linux系统也有效

Esmio avatar Jul 18 '20 08:07 Esmio

perfect now

xcdsycn avatar Jul 19 '20 09:07 xcdsycn

给力

AlbertSaiS avatar Jul 20 '20 07:07 AlbertSaiS

0ck0 avatar Jul 24 '20 03:07 0ck0

好用

Ninshar avatar Jul 29 '20 06:07 Ninshar

👍

stayfoo avatar Jul 31 '20 15:07 stayfoo

感谢!👍

pengqinppp avatar Aug 01 '20 13:08 pengqinppp

🐂🍺

karlinglee93 avatar Aug 02 '20 14:08 karlinglee93

thanks!

ee-lynn avatar Aug 03 '20 14:08 ee-lynn

太厉害了~~~很强

lidapengpeng avatar Aug 07 '20 16:08 lidapengpeng

感谢 有用

Dell-Z avatar Aug 08 '20 01:08 Dell-Z

niubility

classliu avatar Aug 08 '20 04:08 classliu

nice

zguiyang avatar Aug 10 '20 03:08 zguiyang

感谢,有效

uknownothingsnow avatar Aug 10 '20 05:08 uknownothingsnow

感谢

randomlwh avatar Aug 11 '20 05:08 randomlwh

折腾了半天 curl 证书问题,结果用楼主的方法解决了,感谢。

laogui avatar Aug 12 '20 11:08 laogui

666

dehuiZhang avatar Aug 13 '20 11:08 dehuiZhang

非常感谢!有效

LittleShell07 avatar Aug 14 '20 03:08 LittleShell07

学到了 感谢!

haxianhe avatar Aug 19 '20 08:08 haxianhe

有效,thanks

canghai666x avatar Aug 21 '20 01:08 canghai666x

谢谢,果然好使呢

itjinkui avatar Aug 21 '20 02:08 itjinkui

好像指定不同dns,取到的ip也不同呢……

➜  ~ nslookup raw.githubusercontent.com 114.114.114.114   
Server:		114.114.114.114
Address:	114.114.114.114#53

Non-authoritative answer:
raw.githubusercontent.com	canonical name = github.map.fastly.net.
Name:	github.map.fastly.net
Address: 199.232.76.133

➜  ~ nslookup raw.githubusercontent.com 223.5.5.5  
Server:		223.5.5.5
Address:	223.5.5.5#53

Non-authoritative answer:
raw.githubusercontent.com	canonical name = github.map.fastly.net.
Name:	github.map.fastly.net
Address: 151.101.76.133

➜  ~ nslookup raw.githubusercontent.com 8.8.8.8    
Server:		8.8.8.8
Address:	8.8.8.8#53

Non-authoritative answer:
raw.githubusercontent.com	canonical name = github.map.fastly.net.
Name:	github.map.fastly.net
Address: 151.101.0.133
Name:	github.map.fastly.net
Address: 151.101.64.133
Name:	github.map.fastly.net
Address: 151.101.128.133
Name:	github.map.fastly.net
Address: 151.101.192.133

➜  ~

Fisherworks avatar Aug 21 '20 03:08 Fisherworks

好像指定不同dns,取到的ip也不同呢……

➜  ~ nslookup raw.githubusercontent.com 114.114.114.114   
Server:		114.114.114.114
Address:	114.114.114.114#53

Non-authoritative answer:
raw.githubusercontent.com	canonical name = github.map.fastly.net.
Name:	github.map.fastly.net
Address: 199.232.76.133

➜  ~ nslookup raw.githubusercontent.com 223.5.5.5  
Server:		223.5.5.5
Address:	223.5.5.5#53

Non-authoritative answer:
raw.githubusercontent.com	canonical name = github.map.fastly.net.
Name:	github.map.fastly.net
Address: 151.101.76.133

➜  ~ nslookup raw.githubusercontent.com 8.8.8.8    
Server:		8.8.8.8
Address:	8.8.8.8#53

Non-authoritative answer:
raw.githubusercontent.com	canonical name = github.map.fastly.net.
Name:	github.map.fastly.net
Address: 151.101.0.133
Name:	github.map.fastly.net
Address: 151.101.64.133
Name:	github.map.fastly.net
Address: 151.101.128.133
Name:	github.map.fastly.net
Address: 151.101.192.133

➜  ~

嗯嗯,这是当然,github 是肯定有做负载均衡和分布式的部署工作的,不同位置的 dns 服务器获取的 ip 就可能是不同的。如果没有经常需要切换 dns 的需求的话,按照本地设置的 dns 获取的 ip 来设置就可以了。 建议自己 ping 一下,不然不是最快的 ip 地址影响体验。

hawtim avatar Aug 21 '20 03:08 hawtim

老哥🐂🍺 感谢

shawnzhang0322 avatar Aug 26 '20 12:08 shawnzhang0322

老哥感谢

yfj2090 avatar Aug 27 '20 02:08 yfj2090

Thank very much

ThinkCodeStudio avatar Sep 03 '20 06:09 ThinkCodeStudio

🎉实测有效

lingyv avatar Sep 24 '20 10:09 lingyv

优秀

daemonchen avatar Sep 24 '20 10:09 daemonchen

给力啊!

hydyy avatar Sep 24 '20 13:09 hydyy

666666666真的有用

gl0726 avatar Oct 02 '20 05:10 gl0726

奥利给

zhichenliu avatar Oct 10 '20 15:10 zhichenliu

Jianxiongsj avatar Oct 16 '20 04:10 Jianxiongsj

感谢 有用

zgtmy avatar Oct 16 '20 07:10 zgtmy

666

iTofu avatar Oct 16 '20 16:10 iTofu

工具挺好用的 666

oceanyeo avatar Nov 01 '20 16:11 oceanyeo

亲测有效!🐂🍺

jbofun avatar Nov 03 '20 09:11 jbofun

6666,解决了我的问题,🐂🍺

Joackk avatar Nov 06 '20 05:11 Joackk

太牛了,解决了解决了

claireqp avatar Nov 07 '20 07:11 claireqp

谢谢,可以用,但是下载速度好慢....

Vankurua avatar Nov 11 '20 09:11 Vankurua

谢谢,可以用,但是下载速度好慢....

如果有代理(梯子)的话,可以在设置命令行代理,那样速度会快很多

hawtim avatar Nov 13 '20 12:11 hawtim

2020年11月14日还可以用,感谢。

igituser avatar Nov 13 '20 19:11 igituser

太棒了!great!!!

SupremeQingHong avatar Nov 16 '20 08:11 SupremeQingHong

666 成功了

Mars1989sh avatar Nov 16 '20 10:11 Mars1989sh

完美!

leonsux avatar Nov 20 '20 13:11 leonsux

感谢思密达!

chengkaii avatar Nov 24 '20 08:11 chengkaii

Awesome! 平时GitHub里用户的头像(avatar) 都看不到, 除非 VPN 开了全局模式 现在简单了~~

Soul-Clinic avatar Nov 24 '20 10:11 Soul-Clinic

mac os 亲测有效,感谢!

duwenbin0316 avatar Nov 24 '20 12:11 duwenbin0316

mac OS 用R 跑遇到这个问题,用这个方法解决了。

karuie avatar Dec 03 '20 14:12 karuie

有效!棒

yueh-github avatar Dec 05 '20 02:12 yueh-github

thanks,so good!

rookie-hhm avatar Dec 05 '20 11:12 rookie-hhm

亲测有效,感谢!!

Kuiperabxy avatar Dec 08 '20 13:12 Kuiperabxy

太感谢了!!!

Chenlin-marine avatar Dec 12 '20 14:12 Chenlin-marine

 awesome!

simon5057 avatar Dec 13 '20 14:12 simon5057

🐂🍺

aaaa9990aaaa avatar Dec 14 '20 08:12 aaaa9990aaaa

🐂🍺

renyanxu2000 avatar Dec 15 '20 02:12 renyanxu2000

这个方法有效,brew 和 nvm 终于可以用了。

icepy avatar Dec 18 '20 07:12 icepy

验证有效,谢谢!~

suvix avatar Dec 22 '20 08:12 suvix

it works! thanks!

kittychenxx avatar Dec 28 '20 02:12 kittychenxx

背景

笔者最近发现 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 也行动灵活了。

亲测,有效,牛逼。

aaronli09 avatar Dec 30 '20 16:12 aaronli09

image 求解!

jingjing20 avatar Jan 03 '21 15:01 jingjing20

🐂🍺!!!

fanyuecheng avatar Jan 06 '21 07:01 fanyuecheng

image 求解!

我也是!

WYc-Ghost avatar Jan 07 '21 10:01 WYc-Ghost

感谢,此方法有效

yangjing0630 avatar Jan 09 '21 11:01 yangjing0630

👍

xcplus avatar Jan 14 '21 05:01 xcplus

ubuntu20打开host文件方法: nano /etc/hosts

mefengl avatar Jan 17 '21 16:01 mefengl

image 求解!

先输入 ping raw.githubusercontent.com 得到一个 ip 地址,那样才是你能访问并且最快的。

hawtim avatar Jan 18 '21 02:01 hawtim

谢谢,可以用,但是下载速度好慢....

如果有代理(梯子)的话,可以在设置命令行代理,那样速度会快很多

请问具体要怎么设置代理梯子呢?

Ebony59 avatar Jan 30 '21 18:01 Ebony59

卧槽,牛逼啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊

vector1694 avatar Jan 31 '21 10:01 vector1694

谢谢,可以用,但是下载速度好慢....

如果有代理(梯子)的话,可以在设置命令行代理,那样速度会快很多

请问具体要怎么设置代理梯子呢?

如果你用 clash ,右键任务栏会有个复制链接到 命令行 的操作。 如果你用 ss ,你需要在设置里找到对应的端口。 假设你的端口是 12333,在你的终端里输入 export http_proxy=http://127.0.0.1:12333

hawtim avatar Feb 01 '21 05:02 hawtim

@hawtim 您好,为啥我的下载速度只有10kb/s呢?

beizhengren avatar Feb 04 '21 06:02 beizhengren

very good tks

limShaoyi avatar Feb 04 '21 11:02 limShaoyi

good job! thanks a lot

cjy19890822 avatar Feb 05 '21 15:02 cjy19890822

Thanks!

stus3y avatar Feb 07 '21 09:02 stus3y

thx bro!

zhy123zhy321 avatar Feb 09 '21 01:02 zhy123zhy321

it really works, thank you very much~

yanyuLinxi avatar Mar 02 '21 09:03 yanyuLinxi

浏览器明明可以访问raw,但cli下就不行(比如用curl和cmake的file函数)。什么道理0.0.

mrbeardad avatar Mar 04 '21 14:03 mrbeardad

浏览器明明可以访问raw,但cli下就不行(比如用curl和cmake的file函数)。什么道理0.0.

你可以了解一下命令行代理 https://github.com/hawtim/blog/issues/10#issuecomment-770568520

hawtim avatar Mar 05 '21 02:03 hawtim

你这么说我想起来了,我chrome装了ghelper,ghelper好像也会代理到达github的访问,不知道这个代理能不能用于命令行

mrbeardad avatar Mar 05 '21 02:03 mrbeardad

浏览器明明可以访问raw,但cli下就不行(比如用curl和cmake的file函数)。什么道理0.0.

设置 host ,为啥不行,不清楚,涉及系统底层,需要大牛来解答,不知道是否和国情有关.

wget , curl 访问 raw 设置 http_proxy 和 https_proxy 即可完美解决,具体查找此 issues,回复里面有相关设置内容

0ck0 avatar Mar 05 '21 03:03 0ck0

@hawtim 您好,为啥我的下载速度只有10kb/s呢?

可能和你 proxy 软件有关,查找软件文档,看一下是否设置正确

0ck0 avatar Mar 05 '21 03:03 0ck0

你好,我下载nvm 遇到同样问题,添加了hosts 但出了新的问题: 0curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused

helloking001 avatar Mar 15 '21 10:03 helloking001

(2021-3-17)

185.199.108.133 raw.githubusercontent.com 185.199.108.133 user-images.githubusercontent.com 185.199.108.133 avatars2.githubusercontent.com 185.199.108.133 avatars1.githubusercontent.com

aturX avatar Mar 17 '21 03:03 aturX

你好,我下载nvm 遇到同样问题,添加了hosts 但出了新的问题: 0curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused

https://github.com/hawtim/blog/issues/10#issuecomment-800761866

aturX avatar Mar 17 '21 03:03 aturX

谢谢,可以用,但是下载速度好慢....

如果有代理(梯子)的话,可以在设置命令行代理,那样速度会快很多

请问具体要怎么设置代理梯子呢?

我用了ssr,但是一样: OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to raw.githubusercontent.com:443

hbj111 avatar Mar 19 '21 12:03 hbj111

挂ShadowsocksR-dotnet4.0 ,加本地host修改:185.199.108.133 raw.githubusercontent.com 都无法进行操作。可见有多可恶。

hbj111 avatar Mar 19 '21 12:03 hbj111

(2021-3-17)

185.199.108.133 raw.githubusercontent.com 185.199.108.133 user-images.githubusercontent.com 185.199.108.133 avatars2.githubusercontent.com 185.199.108.133 avatars1.githubusercontent.com

同样不行。

hbj111 avatar Mar 19 '21 12:03 hbj111

谢谢,可以用,但是下载速度好慢....

如果有代理(梯子)的话,可以在设置命令行代理,那样速度会快很多

请问具体要怎么设置代理梯子呢?

如果你用 clash ,右键任务栏会有个复制链接到 命令行 的操作。 如果你用 ss ,你需要在设置里找到对应的端口。 假设你的端口是 12333,在你的终端里输入 export http_proxy=http://127.0.0.1:12333

请教:我的SSR连接的端口是:15000商品,在终端输入: export http_proxy=http://127.0.0.1:15000,这里的127.0.0.1是固定的,还是ssr上的连接IP?

hbj111 avatar Mar 19 '21 12:03 hbj111

(2021-3-17) 185.199.108.133 raw.githubusercontent.com 185.199.108.133 user-images.githubusercontent.com 185.199.108.133 avatars2.githubusercontent.com 185.199.108.133 avatars1.githubusercontent.com

同样不行。

你需要把 每个可能的IP都加上。 就像这样:

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

185.199.108.133 user-images.githubusercontent.com
185.199.109.133 user-images.githubusercontent.com
185.199.110.133 user-images.githubusercontent.com
185.199.111.133 user-images.githubusercontent.com

....

aturX avatar Mar 22 '21 01:03 aturX