关于GitHub网页中头像无法显示的问题

解决GitHub打开头像不显示问题

以前解决完,换个电脑又出现这个问题。 百度了一堆,各种修改hosts文件,结果还是没有解决,真的很烦

解决(更新于:2021/01/21)

Windows10系统hosts路径:

C:WindowsSystem32driversetc

添加:

199.232.96.133 avatars.githubusercontent.com

关于头像不显示解决就是这行。如果失效了,请按我后面的方法去重新获取IP。

附录

附上我的hosts文件中GitHub的配置(更新于:2021/01/21)

# GitHub Start
52.74.223.119 github.com

52.74.223.119 gist.github.com
54.169.195.247 api.github.com

199.232.96.133 avatars.githubusercontent.com
185.199.111.153 assets-cdn.github.com
199.232.96.133 raw.githubusercontent.com
199.232.96.133 gist.githubusercontent.com
199.232.96.133 cloud.githubusercontent.com
199.232.96.133 camo.githubusercontent.com
199.232.96.133 avatars0.githubusercontent.com
199.232.96.133 avatars1.githubusercontent.com
199.232.96.133 avatars2.githubusercontent.com
199.232.96.133 avatars3.githubusercontent.com
199.232.96.133 avatars4.githubusercontent.com
199.232.96.133 avatars5.githubusercontent.com
199.232.96.133 avatars6.githubusercontent.com
199.232.96.133 avatars7.githubusercontent.com
199.232.96.133 avatars8.githubusercontent.com
199.232.96.133 user-images.githubusercontent.com
185.199.109.154 github.githubassets.com
# GitHub End

方法

下面教大家怎么获取最新IP

注:由于这种域名不是经常变,我感觉第1、2步没必要做,直接复制就可以了 avatars.githubusercontent.com
  1. 鼠标在头像上,右键 --> 检查
  2. 复制这里的网址,只需要avatars.githubusercontent.com这部分就可以了
  3. 打开IPAddress.com
https://www.ipaddress.com/
  1. 把刚才复制的网址粘贴进去,回车
  2. 直接往下拖,就可以看到我们想要的ip
  3. 格式:
IP + 空格 + 域名 199.232.96.133 avatars.githubusercontent.com

注:由于IP会经常性变化,所以旧的IP有可能失效,就需要重新获取最新的IP地址。

推荐

  1. 给大家推荐一个好用的工具
https://github.com/oldj/SwitchHosts

GitHub开源项目,可以方便的修改hosts文件,自由切换不同环境下的hosts配置。

  1. 这里会更新较全的hosts文件配置,原谅我没有体会到这个项目的妙用 /捂脸
https://github.com/googlehosts/hosts

先就这样吧,以后有需要的再补充更新。

经验分享 程序员 微信小程序 职场和发展