git clone失败,报错”Failed to connect to github.com port 443:Connection time out“,解决方法

本文详细记录了解决在服务器上使用GitClone项目时遇到的长时间等待和连接超时问题的过程,通过修改/etc/hosts文件中与github.com相关的条目,最终成功解决了问题。

       如下图,在服务器上git clone项目时,总是一直显示“Cloning into ...”,过了好久才显示”fatal: unable to access ... :Failed to connect to github.com port 443: Connection timed out“.

     

      最开始,以为是网络问题,但是后来发现网络连接没问题。

      然后又查帖,有说是代理的问题:

      尝试了 网上的 设置代理:

git config --global https.proxy [http://127.0.0.1:1080](http://127.0.0.1:1080/)

git config --global https.proxy [https://127.0.0.1:1080](https://127.0.0.1:1080/)

和取消代理:

git config --global --unset http.proxy

git config --global --unset https.proxy

      尝试后都没有解决问题,才发现报的都不是一个错,不是这个port 443的问题。

      最后参考 https://blog.youkuaiyun.com/hustsselbj/article/details/46842191?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase  和 https://blog.youkuaiyun.com/qq_45435600/article/details/98177142 终于解决了。

 

就是 修改 /etc/hosts 文件

vim /etc/hosts 

把跟github.com 相关的行注释掉,重新git clone,就成功啦!

评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值