Failed to connect to github.com port 443: Operation timed out

本文介绍了在遇到Git push操作超时时,如何通过修改hosts文件,添加GitHub的IP地址来解决这个问题。具体步骤包括访问特定网址获取GitHub的IP,然后在hosts文件中添加该IP,最后验证是否能成功ping通。这种方法能有效提高GitHub的访问速度。
摘要由CSDN通过智能技术生成

今天在git push东西的时候发现超时了,找了好多办法也解决不了,后面发现配置一下hosts就行了,所以分享一下,首先找到github有用的ip:

访问网址:http://ping.chinaz.com/github.com

找到一个可用的ip:

在这里插入图片描述
然后填入hosts里:

sudo vim /etc/hosts

添加一行

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost

52.74.223.119  github.com

保存退出:

:wq

本地ping一下:

➜  Frequent-use git:(master) ping github.com
PING github.com (52.74.223.119): 56 data bytes
64 bytes from 52.74.223.119: icmp_seq=0 ttl=37 time=223.711 ms
64 bytes from 52.74.223.119: icmp_seq=1 ttl=37 time=224.997 ms
^C
--- github.com ping statistics ---
3 packets transmitted, 2 packets received, 33.3% packet loss
round-trip min/avg/max/stddev = 223.711/224.354/224.997/0.643 ms

发现能ping通就可以使用了哈。

参考文献

Failed to connect to github.com port 443 Timed out

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

农民小飞侠

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值