hawtim.github.io
hawtim.github.io copied to clipboard
如何解决类似 curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused 的问题
背景
笔者最近发现 github 的用户头像和自己文章中的图片显示不出来了。然后今天发现安装 homeBrew 和 nvm 出现了标题的报错信息。
以上是安装 pnpm 的报错信息,可以发现,脚本需要到 raw.githubusercontent.com 上拉取代码。
网上搜索了一下,发现是 github 的一些域名的 DNS 解析被污染,导致DNS 解析过程无法通过域名取得正确的IP地址。
DNS 污染
DNS 污染,感兴趣的朋友可以去了解一下。
解决方案
打开 https://www.ipaddress.com/ 输入访问不了的域名
查询之后可以获得正确的 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 也行动灵活了。
这个方法有效 🐂🍺
亲测有效👍👍
使用SwitchHosts配置host之后
一直失败的RVM安装可以正常安装了
这个方法有效,前排支持!
感谢感谢,亲测有效。
感谢
有效!
世界终于回归正常了,感谢!
🐂🍺,亲测有效
perfect
666 完美
谢谢,亲测有效!
really help
谢谢,Linux系统也有效
perfect now
给力
牛
好用
👍
感谢!👍
🐂🍺
thanks!
太厉害了~~~很强
感谢 有用
niubility
nice
感谢,有效
感谢
折腾了半天 curl 证书问题,结果用楼主的方法解决了,感谢。
666
非常感谢!有效
学到了 感谢!
有效,thanks
谢谢,果然好使呢
好像指定不同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
➜ ~
好像指定不同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 地址影响体验。
老哥🐂🍺 感谢
老哥感谢
Thank very much
🎉实测有效
优秀
给力啊!
666666666真的有用
奥利给
赞
感谢 有用
666
工具挺好用的 666
亲测有效!🐂🍺
6666,解决了我的问题,🐂🍺
太牛了,解决了解决了
谢谢,可以用,但是下载速度好慢....
谢谢,可以用,但是下载速度好慢....
如果有代理(梯子)的话,可以在设置命令行代理,那样速度会快很多
2020年11月14日还可以用,感谢。
太棒了!great!!!
666 成功了
完美!
感谢思密达!
Awesome! 平时GitHub里用户的头像(avatar) 都看不到, 除非 VPN 开了全局模式 现在简单了~~
mac os 亲测有效,感谢!
mac OS 用R 跑遇到这个问题,用这个方法解决了。
有效!棒
thanks,so good!
亲测有效,感谢!!
太感谢了!!!
awesome!
🐂🍺
🐂🍺
这个方法有效,brew 和 nvm 终于可以用了。
验证有效,谢谢!~
it works! thanks!
背景
笔者最近发现 github 的用户头像和自己文章中的图片显示不出来了。然后今天发现安装 homeBrew 和 nvm 出现了标题的报错信息。
以上是安装 pnpm 的报错信息,可以发现,脚本需要到 raw.githubusercontent.com 上拉取代码。
网上搜索了一下,发现是 github 的一些域名的 DNS 解析被污染,导致DNS 解析过程无法通过域名取得正确的IP地址。
DNS 污染
DNS 污染,感兴趣的朋友可以去了解一下。
解决方案
打开 https://www.ipaddress.com/ 输入访问不了的域名
查询之后可以获得正确的 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 也行动灵活了。
亲测,有效,牛逼。
求解!
🐂🍺!!!
求解!
我也是!
感谢,此方法有效
👍
ubuntu20打开host文件方法:
nano /etc/hosts
求解!
先输入 ping raw.githubusercontent.com 得到一个 ip 地址,那样才是你能访问并且最快的。
谢谢,可以用,但是下载速度好慢....
如果有代理(梯子)的话,可以在设置命令行代理,那样速度会快很多
请问具体要怎么设置代理梯子呢?
卧槽,牛逼啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊
谢谢,可以用,但是下载速度好慢....
如果有代理(梯子)的话,可以在设置命令行代理,那样速度会快很多
请问具体要怎么设置代理梯子呢?
如果你用 clash ,右键任务栏会有个复制链接到 命令行 的操作。
如果你用 ss ,你需要在设置里找到对应的端口。
假设你的端口是 12333,在你的终端里输入 export http_proxy=http://127.0.0.1:12333
@hawtim 您好,为啥我的下载速度只有10kb/s呢?
very good tks
good job! thanks a lot
Thanks!
thx bro!
it really works, thank you very much~
浏览器明明可以访问raw,但cli下就不行(比如用curl和cmake的file函数)。什么道理0.0.
浏览器明明可以访问raw,但cli下就不行(比如用curl和cmake的file函数)。什么道理0.0.
你可以了解一下命令行代理 https://github.com/hawtim/blog/issues/10#issuecomment-770568520
你这么说我想起来了,我chrome装了ghelper,ghelper好像也会代理到达github的访问,不知道这个代理能不能用于命令行
浏览器明明可以访问raw,但cli下就不行(比如用curl和cmake的file函数)。什么道理0.0.
设置 host ,为啥不行,不清楚,涉及系统底层,需要大牛来解答,不知道是否和国情有关.
wget , curl 访问 raw 设置 http_proxy 和 https_proxy 即可完美解决,具体查找此 issues,回复里面有相关设置内容
@hawtim 您好,为啥我的下载速度只有10kb/s呢?
可能和你 proxy 软件有关,查找软件文档,看一下是否设置正确
你好,我下载nvm 遇到同样问题,添加了hosts 但出了新的问题: 0curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
(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
你好,我下载nvm 遇到同样问题,添加了hosts 但出了新的问题: 0curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
https://github.com/hawtim/blog/issues/10#issuecomment-800761866
谢谢,可以用,但是下载速度好慢....
如果有代理(梯子)的话,可以在设置命令行代理,那样速度会快很多
请问具体要怎么设置代理梯子呢?
我用了ssr,但是一样: OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to raw.githubusercontent.com:443
挂ShadowsocksR-dotnet4.0 ,加本地host修改:185.199.108.133 raw.githubusercontent.com 都无法进行操作。可见有多可恶。
(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
同样不行。
谢谢,可以用,但是下载速度好慢....
如果有代理(梯子)的话,可以在设置命令行代理,那样速度会快很多
请问具体要怎么设置代理梯子呢?
如果你用 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?
(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
....