访问raw.githubusercontent.com失败问题的处理

1 问题

GitHub上的项目的有些资源是放在raw.githubusercontent.com上的,通常我们在安装某些软件的时候会从该地址下载资源,直接访问的话经常容易失败。

sh 复制代码
# 安装operator
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.1.0_release/deploy/operator.yaml
# 报错内容
The connection to the server raw.githubusercontent.com was refused - did you specify the right host or port?

分析原因:因为神秘力量,域名解析不了,所以访问不了。

解决方法:不用域名登录,直接用ip登录,或者去/etc/hosts里设置下域名解析

2 解决方法

利用修改hosts文件的方法

hosts文件中有用的内容都以一行一行的形式排布,格式为 ip地址 + 空格 + 域名 ,比如 140.82.114.4 github.com ,这样设备在访问 github.com 时就会直接访问 140.82.114.4 这个地址了,而不用向DNS服务器查询。

2.1 查询出raw.githubusercontent.com的ip地址

我们利用查询网查询,查询网的地址为:https://www.ip138.com

查询结果为

2.2 在/etc/hosts里填写如下内容

sh 复制代码
# 把 185.199.109.133 raw.githubusercontent.com 追加到/etc/hosts

echo "185.199.109.133  raw.githubusercontent.com" >> /etc/hosts

3.2 再次执行安装语句,执行成功

sh 复制代码
# 再次执行安装operator
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.1.0_release/deploy/operator.yaml
# 下面为执行成功的信息
namespace/oceanbase-system created
customresourcedefinition.apiextensions.k8s.io/obclusterbackups.oceanbase.oceanbase.com created
customresourcedefinition.apiextensions.k8s.io/obclusterrestores.oceanbase.oceanbase.com created
......

总结

总的来说修改hosts文件来解决一些网站因为DNS原因无法访问或者访问缓慢的情况还是非常方便的。这个方法也可以用于改善 github.comgithub.global.ssl.fastly.net 等网站的访问情况。

相关推荐
木子欢儿10 小时前
Intel 架构的 MacBook Pro 运行 Linux 发热量高解决
linux·运维·服务器
午安~婉11 小时前
GitHub Token/ GitHub Stats统计显示图异常
前端·github·vercel·github token
dong_junshuai13 小时前
每天一个开源项目#59 AirLLM:27.6K星,3.72GB显存跑2.8T模型
人工智能·程序员·github
lpfasd12313 小时前
2026年第31周GitHub趋势周报
github
会编程的土豆13 小时前
Go 模板初识
linux·运维·服务器
Jul1en_14 小时前
【Claude Code Compact】源码级别的学习上下文压缩
java·前端·学习·github·ai编程
逛逛GitHub15 小时前
Karpathy 刚发了一个帖子,怎么判断一个新模型到底行不行?
github
m4Rk_15 小时前
【论文阅读】Agent 记忆机制(28):MEM1——将记忆压缩融入推理,实现近似恒定上下文的长程智能体
论文阅读·人工智能·学习·开源·github
逛逛GitHub15 小时前
盘点 17 个 7 月份 GitHub 上夯夯夯的开源项目。
github
aFakeProgramer15 小时前
Linux版本兼容问题及RTA-VRTE环境配置笔记
linux·笔记