Github 图片不显示问题排查

问题现象

最近一段时间,经常有同学给我们反馈,我们的 Github Readme 文件中图片显示不出来,问题现象如下:

之前其实也有遇到这类问题,但是一直没有认真排查过,这次刚好有时间,就认真看看。

排查思路

2.1. 查看报错原因

当图片无法正常加载时,从浏览器的控制台可以看到如下报错: 因为是此仓库保存的图片,检查后可以看到这个图片的源文件都是在的,但是点击诸如这样的链接:raw.githubusercontent.com/Tencent-RTC... 后,却提示:raw.githubusercontent.com 拒绝了我们的连接请求。

2.2. ping 网站地址

通过 raw.githubusercontent.com 这个地址,发现确实无法正常访问:

bash 复制代码
tatemin@TATEMIN-MC5:~ % ping raw.githubusercontent.com
PING raw.githubusercontent.com (0.0.0.0): 56 data bytes
ping: sendto: Socket is not connected
ping: sendto: Socket is not connected
Request timeout for icmp_seq 0
ping: sendto: Socket is not connected
Request timeout for icmp_seq 1
ping: sendto: Socket is not connected
Request timeout for icmp_seq 2
ping: sendto: Socket is not connected
Request timeout for icmp_seq 3

2.3. ping IP 地址

raw.githubusercontent.com 无法正常 ping 通,然后我们通过 IP 查询工具 查询到该地址对应的 IP:185.199.109.133:

然后接着 ping 这个地址:

bash 复制代码
tatemin@TATEMIN-MC5:~ % ping 185.199.110.133
PING 185.199.110.133 (185.199.110.133): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
64 bytes from 185.199.110.133: icmp_seq=4 ttl=64 time=193.524 ms
Request timeout for icmp_seq 5
Request timeout for icmp_seq 6
Request timeout for icmp_seq 7
Request timeout for icmp_seq 8
64 bytes from 185.199.110.133: icmp_seq=9 ttl=64 time=189.056 ms
Request timeout for icmp_seq 10
Request timeout for icmp_seq 11
Request timeout for icmp_seq 12
Request timeout for icmp_seq 13
64 bytes from 185.199.110.133: icmp_seq=14 ttl=64 time=192.879 ms

从输出结果显示,有部分请求超时,但也有部分请求得到了响应,说明您的网络连接存在一些问题,但并非完全无法连接,跟直接 ping 域名的结果是不一样的。

问题解决

在 Mac 上通过终端工具,修改 hosts 文件如下:

bash 复制代码
tatemin@TATEMIN-MC5:~ % cat /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1	localhost
255.255.255.255	broadcasthost
::1             localhost
185.199.110.133 raw.githubusercontent.com // 此次新增

然后,关闭浏览器,再重新打开页面,图片资源就可以正常加载了~

相关推荐
突然暴富的我7 小时前
Git 的基本概念和使用方式。
前端·git·json·github
福星高照~9 小时前
Git、Github、tortoiseGit下载安装调试全套教程
git·github
dadalaohua9 小时前
【开源项目】LocalSend 局域网文件传输工具
笔记·学习·github
辣码甄源15 小时前
清新简约之美,开源个人博客:Jekyll Theme Chirpy
开源·github
老衲有点帅16 小时前
Git 常用命令及其作用
git·github
小远披荆斩棘19 小时前
Github与本地仓库建立链接、Git命令(或使用Github桌面应用)
git·github
粥里有勺糖1 天前
「豆包Marscode体验官」MarsCode IDE 搭建 VitePress 博客并使用 GitHub 部署
前端·程序员·github
前端达人1 天前
基于React和TypeScript的开源白板项目(Github项目分享)
前端·react.js·typescript·前端框架·github
阳爱铭1 天前
GitHub:现代软件开发的协作平台
驱动开发·后端·中间件·面试·架构·github·学习方法
OpenTiny社区2 天前
7月6日 VueConf 技术大会即将在深圳举办
前端·vue.js·github