解决GitHub不显示图片问题
刚开始使用github时很多时候会碰到图片不显示的问题以下为解决方法
不显示图片原因:一般是因为DNS无法解析到图片外链地址的ip地址
解决方法:很简单,我们可以通过外国的ip地址测试找到该域名具体对应的ip地址,之后手动地加到我们本机的host文件中(相当于DNS映射)
具体步骤
第一步:检查域名
我们可以右键点中不能显示的图片,点击检查,点击控制台,可以看到failed to load 字样,后面就是没有显示出来的图片地址:

我这里是https://raw.githubusercontent.com/shishan100/Java-Interview-Advanced/master/images/es-cluster-0.png
我们要查找的域名是http://到.com之间:在这里为:raw.githubusercontent.com
第二步:查找域名对应的IP
访问 https://www.ipaddress.com/ ,在页面输入刚刚找到的域名:raw.githubusercontent.com
可以得到IP地址如下:


第三步:修改hosts文件
找到本机hosts文件,一般路径地址为:C:\Windows\System32\drivers\etc\hosts
打开hosts修改,将上面对应的IP和域名放到hosts文件末尾
即添加:
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
2606:50c0:8000::154 raw.githubusercontent.com
2606:50c0:8001::154 raw.githubusercontent.com
2606:50c0:8002::154 raw.githubusercontent.com
2606:50c0:8003::154 raw.githubusercontent.com
ps: 添加完此映射关系之后,可以使用这个命令刷新下本地的DNS缓存:ipconfig/flush,打开CMD,输入 ipconfig/flushdns 即可。
以下是重新显示出来的图片:
下面是比较全的dns配置,可以直接加到末尾
# GitHub Start
140.82.113.3 github.com
140.82.114.20 gist.github.com
151.101.184.133 assets-cdn.github.com
151.101.184.133 raw.githubusercontent.com
151.101.184.133 gist.githubusercontent.com
151.101.184.133 cloud.githubusercontent.com
151.101.184.133 camo.githubusercontent.com
151.101.184.133 avatars0.githubusercontent.com
199.232.68.133 avatars0.githubusercontent.com
199.232.28.133 avatars1.githubusercontent.com
151.101.184.133 avatars1.githubusercontent.com
151.101.184.133 avatars2.githubusercontent.com
199.232.28.133 avatars2.githubusercontent.com
151.101.184.133 avatars3.githubusercontent.com
199.232.68.133 avatars3.githubusercontent.com
151.101.184.133 avatars4.githubusercontent.com
199.232.68.133 avatars4.githubusercontent.com
151.101.184.133 avatars5.githubusercontent.com
199.232.68.133 avatars5.githubusercontent.com
151.101.184.133 avatars6.githubusercontent.com
199.232.68.133 avatars6.githubusercontent.com
151.101.184.133 avatars7.githubusercontent.com
199.232.68.133 avatars7.githubusercontent.com
151.101.184.133 avatars8.githubusercontent.com
199.232.68.133 avatars8.githubusercontent.com
# GitHub End
再次失效的话可以用cmd刷新:ipconfig /flushdns

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY