解决ubuntu18.04的raw.githubusercontent.com无法连接问题

ubuntu18.04报错,raw.githubusercontent.com无法连接

1. IP查询:

. 去这个网站,查询无法连接网址的IP地址

在终端里ping这个网址原来是ping不通的 (ping的使用方法,终端输入 $ ping www.baidu.com) 最后我得到的是: 151.101.84.133 以下是网上找的一些说不定用得到的网址IP:

IP 网址 52.74.223.119 right-aligned github.com 192.30.253.119 gist.github.com 54.169.195.247 api.github.com 185.199.111.153 assets-cdn.github.com 151.101.76.133 这个地方76在我电脑上得改成84 raw.githubusercontent.com 151.101.108.133 user-images.githubusercontent.com 151.101.76.133 gist.githubusercontent.com 151.101.76.133 cloud.githubusercontent.com 151.101.76.133 camo.githubusercontent.com 151.101.76.133 avatars0.githubusercontent.com 151.101.76.133 avatars1.githubusercontent.com 151.101.76.133 avatars2.githubusercontent.com 151.101.76.133 avatars3.githubusercontent.com 151.101.76.133 avatars4.githubusercontent.com 151.101.76.133 avatars5.githubusercontent.com 151.101.76.133 avatars6.githubusercontent.com 151.101.76.133 avatars7.githubusercontent.com 151.101.76.133 avatars8.githubusercontent.com

2.修改hosts

Hosts是一个没有扩展名的系统文件,可以用记事本等工具打开,其作用就是将一些常用的网址域名与其对应的IP地址建立一个关联“数据库”,当用户在浏览器中输入一个需要登录的网址时,系统会首先自动从Hosts文件中寻找对应的IP地址,一旦找到,系统会立即打开对应网页,如果没有找到,则系统会再将网址提交DNS域名解析服务器进行IP地址的解析。

sudo vi /etc/hosts
sudo vim /etc/hosts
sudo gedit /etc/hosts

上面三条指令都是OK的,看你使用什么编辑器,本质上是修改hosts文件,加上我们之前查到的那个IP地址 添加下面代码至hosts

151.101.84.133  raw.githubusercontent.com

理论上现在就可以ping成功那个网址了,报错解决!

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