git clone 时Failed to connect to github.com port 443:connection timed out 怎么办
git clone 时Failed to connect to github.com port 443:connection timed out 怎么办
·
第一种办法:设置全局代理
设置全局代理:
git config --global http.proxy http://127.0.0.1:1080
git config --global https.proxy http://127.0.0.1:1080
再次尝试,一般情况下可以正常clone。
如果遇到以下报错:
Failed to connect to 127.0.0.1 port 1080 after 2070 ms: Connection refused
请采取第二种方法。
第二种方法:修改hosts文件(以windows系统为例)
1.打开https://github.com.ipaddress.com/ 如下图:
记录IP地址(可能与上图有差异)!
2.打开https://fastly.net.ipaddress.com/github.global.ssl.fastly.net#ipinfo 如下图:
记录4个IPV4地址!
3.修改hosts文件
windows的hosts文件在C:\Windows\System32\drivers\etc\文件夹下,
在hosts文件夹中添加刚才复制的ip,格式如下:
如果遇到访问权限的问题,遵守以下方法操作即可修改权限:
修改完权限后,需要刷新dns,cmd命令如下(需要进入管理员模式!):
#刷新DNS缓存
ipconfig /flushdns
#展示DNS缓存
ipconfig /displaydns
大功告成!,愉快的进行git clone吧!
更多推荐
已为社区贡献1条内容
所有评论(0)