问题
平时用github的时候用的都好好的,今天晚上传代码的时候,git push久久没有反应,试了n多次之后出现下面错误,但是打开其他网页正常,从错误中可以看出应该是和该IP有关,应该是访问超时之类的问题
ssh_dispatch_run_fatal: Connection to 13.250.177.223: Software caused connection abort
fatal: Could not read fro remote repository.
Please make sure you have the correct access rights and the repository exists.
产生原因
检查是否由于IP地址无法访问导致,打开cmd或者iTerm,输入ping命令查看github.com访问情况,确实IP无法访问到,一般无非就是DNS解析出来的IP,我们的网络无法访问到造成的
解决方案
解决方案有两种,以下方案选其一即可,第二种不让发
修改hosts文件
找到Hosts文件所在位置,在末尾添加上下面这段文本,保存,原理就是通过Hosts文件指定访问github的IP,而不是通过DNS去访问
192.30.255.112 github.com git
185.31.16.184 github.global.ssl.fastly.net
以下是各个系统Hosts文件所在位置:
- Windows:
C:\Windows\System32\drivers\etc\hosts
(Windows注意使用管理员权限打开,记事本或者VS code均可) - Mac:
/etc/hosts
- Linux:
/etc/hosts
(非Root用户注意权限)