GitHub 无法访问解决方案
Wupq 2021-05-01 Github
# 前言
GitHub是一个面向开源及私有软件项目的托管平台,因为只支持Git 作为唯一的版本库格式进行托管,故名GitHub。
由于GitHub是一个国外网站,在国内访问速度如何呢?
我们通过浏览器访问下https://github.com,但是页面很久才能打开,要等待一个较长时间,如下图所示:
接着我们打开系统工具下的命令提示符,输入 ping github.com,但可惜的是出现了“请求超时”的信息提示,如下图所示:
# 解决办法
# 第一步:查看 GitHub 的 IP 地址
进入网址 https://github.com.ipaddress.com (opens new window)
# 第二步:查看 GitHub 的 域名 IP
进入网址 https://fastly.net.ipaddress.com/github.global.ssl.fastly.net (opens new window)
# 第三步: 查看 GitHub 的 静态资源 IP
进入网址 https://github.com.ipaddress.com/assets-cdn.github.com (opens new window)
# 第四步: 修改 Hosts 配置文件
将上面三步所得的 IP
写进 hosts
文件里
macOS hosts 文件路径: /etc/hosts
Windows hosts 文件路径: C:\Windows\System32\drivers\etc\hosts
# GitHub
140.82.112.3 github.com
199.232.69.194 github.global.ssl.fastly.net
185.199.108.153 assets-cdn.github.com
185.199.109.153 assets-cdn.github.com
185.199.110.153 assets-cdn.github.com
185.199.111.153 assets-cdn.github.com
2606:50c0:8000::153 assets-cdn.github.com
2606:50c0:8001::153 assets-cdn.github.com
2606:50c0:8002::153 assets-cdn.github.com
2606:50c0:8003::153 assets-cdn.github.com
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
# 注意事项
- 这些
IP
过一段时间会变动,所以网上很多教程都是直接复制第四步,却没有效果,这时候一定记得要查一下IP
是否一样。 - 如果在浏览器开着
GitHub
(无法访问状态)的时候修改了hosts
文件需要重启浏览器。
参考博客来自我的前端导师