最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】git clone出错:Failed to connect to github.com port 443 Operation timed out

Git crifan 35124浏览 0评论

1.同事的Mac笔记本中,之前用carthage update,出现此错误

把git版本升级后,版本是:2.8.3

然后去直接试试

git clone,

还是出错:

brancepengdeMacBook-Pro:keyoutong minglong$ git clone https://github.com/rhodgkins/SwiftHTTPStatusCodes.git/
Cloning into ‘SwiftHTTPStatusCodes’…
fatal: unable to access ‘https://github.com/rhodgkins/SwiftHTTPStatusCodes.git/’: Failed to connect to github.com port 443: Operation timed out

-》

看来和Carthage 没有关系

2.在另外我的正常的Mac中:

(1)开启了ss翻墙,自动代理

(2)关闭了ss翻墙

都是可以正常clone的:

➜  testGit git clone https://github.com/rhodgkins/SwiftHTTPStatusCodes.git/
Cloning into ‘SwiftHTTPStatusCodes’…
remote: Counting objects: 647, done.
remote: Total 647 (delta 0), reused 0 (delta 0), pack-reused 647
Receiving objects: 100% (647/647), 109.94 KiB | 28.00 KiB/s, done.
Resolving deltas: 100% (349/349), done.
Checking connectivity… done.

-》看来和翻墙没有关系

3.搜:

mac git github 443

mac git clone Failed to connect to github.com port 443 Operation timed out

git clone Failed to connect to github.com port 443 Operation timed out

参考:

在git@osc上创建仓库,错误提示:error: Failed connect to git.oschina.net:443 – 开源中国社区

正常的Mac中,ping:

➜  testGit ping github.com
PING github.com (192.30.253.113): 56 data bytes
64 bytes from 192.30.253.113: icmp_seq=0 ttl=50 time=399.557 ms
64 bytes from 192.30.253.113: icmp_seq=1 ttl=50 time=357.668 ms
64 bytes from 192.30.253.113: icmp_seq=2 ttl=50 time=434.028 ms
^C

<div–<- github.com ping statistics —

3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 357.668/397.084/434.028/31.223 ms

出错的Mac中,ping github都出错:

brancepengdeMacBook-Pro:~ minglong$ ping github.com
PING github.com (192.30.252.131): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
Request timeout for icmp_seq 4
Request timeout for icmp_seq 5
Request timeout for icmp_seq 6
Request timeout for icmp_seq 7

但是可以正常上网,可以ping其它网址:

brancepengdeMacBook-Pro:~ minglong$ ping www.baidu.com
PING www.a.shifen.com (180.97.33.108): 56 data bytes
64 bytes from 180.97.33.108: icmp_seq=0 ttl=55 time=10.103 ms
64 bytes from 180.97.33.108: icmp_seq=1 ttl=55 time=7.232 ms
64 bytes from 180.97.33.108: icmp_seq=2 ttl=55 time=7.521 ms
64 bytes from 180.97.33.108: icmp_seq=3 ttl=55 time=7.787 ms
64 bytes from 180.97.33.108: icmp_seq=4 ttl=55 time=13.791 ms
^C

<div–<- www.a.shifen.com ping statistics —

5 packets transmitted, 5 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 7.232/9.287/13.791/2.472 ms

ping github.com Request timeout for icmp_seq

为什么 github 丢包这么多 – V2EX

ping · GitHub

关于2.5.1稳定版的问题 · Issue #1177 · XX-net/XX-Net · GitHub

git遇到的诡异错误: Failed connect to github.com:443 – hustsselbj的专栏 – 博客频道 – CSDN.NET

出错的mac去路由,果然有问题:

brancepengdeMacBook-Pro:~ minglong$ traceroute 192.30.252.131
traceroute to 192.30.252.131 (192.30.252.131), 64 hops max, 52 byte packets
 1  192.168.1.1 (192.168.1.1)  8.683 ms  21.586 ms  9.471 ms
 2  100.82.0.1 (100.82.0.1)  5.922 ms  30.413 ms  13.791 ms
 3  218.4.12.97 (218.4.12.97)  14.866 ms
    218.94.215.5 (218.94.215.5)  46.154 ms
    218.94.215.9 (218.94.215.9)  106.304 ms
 4  221.224.229.229 (221.224.229.229)  27.456 ms
    218.94.225.169 (218.94.225.169)  19.655 ms
    221.224.229.229 (221.224.229.229)  11.858 ms
 5  202.97.92.21 (202.97.92.21)  26.704 ms  103.900 ms  27.872 ms
 6  202.97.50.246 (202.97.50.246)  11.703 ms  13.720 ms  17.590 ms
 7  * * 202.97.91.66 (202.97.91.66)  79.904 ms
 8  202.97.50.90 (202.97.50.90)  225.717 ms  204.989 ms *
 9  202.97.50.54 (202.97.50.54)  682.562 ms
    202.97.50.26 (202.97.50.26)  308.171 ms  289.715 ms
10  * xe-8-3-2.edge2.sanjose3.level3.net (4.53.210.205)  470.361 ms *
11  * ae-1-3508.ear1.washington39.level3.net (4.69.159.229)  536.557 ms *
12  * * *
13  * * *
14  * * *
15  * * *
16  * * *
17  * * *
18  * * *
19  * * *
20  * * *
21  * * *
22  * * *
23  * * *
24  * * *
25  * * *
26  * * *
27  * * *
28  * * *
29  * * *
30  * * *
31  * * *
32  * * *
33  * *^C

而我这里貌似也是联不通:

➜  testGit traceroute 192.30.253.112
traceroute to 192.30.253.112 (192.30.253.112), 64 hops max, 52 byte packets
 1  192.168.1.1 (192.168.1.1)  3.887 ms  1.695 ms  2.237 ms
 2  100.82.0.1 (100.82.0.1)  5.174 ms  3.715 ms  3.183 ms
 3  218.94.215.9 (218.94.215.9)  6.147 ms
    218.4.12.85 (218.4.12.85)  7.070 ms
    218.4.12.97 (218.4.12.97)  8.516 ms
 4  221.224.229.221 (221.224.229.221)  10.806 ms
    218.94.225.169 (218.94.225.169)  16.702 ms
    221.224.229.221 (221.224.229.221)  12.130 ms
 5  202.97.92.21 (202.97.92.21)  11.435 ms
    202.97.92.9 (202.97.92.9)  16.854 ms
    202.97.92.21 (202.97.92.21)  20.503 ms
 6  202.97.35.222 (202.97.35.222)  61.277 ms
    202.97.33.110 (202.97.33.110)  12.044 ms
    202.97.35.222 (202.97.35.222)  61.680 ms
 7  202.97.33.138 (202.97.33.138)  69.206 ms
    202.97.35.106 (202.97.35.106)  63.453 ms
    202.97.35.146 (202.97.35.146)  12.098 ms
 8  202.97.58.190 (202.97.58.190)  274.388 ms
    202.97.50.126 (202.97.50.126)  195.472 ms
    202.97.58.198 (202.97.58.198)  332.424 ms
 9  202.97.50.78 (202.97.50.78)  204.669 ms
    202.97.50.26 (202.97.50.26)  185.291 ms
    202.97.50.78 (202.97.50.78)  214.345 ms
10  * * xe-8-2-3.edge2.sanjose3.level3.net (4.53.210.209)  323.663 ms
11  * * *
12  * * *
13  * * *
^C

route 查看本机路由

查看本机路由表(一)折翼天使新浪博客

[很有用的]Windows和Linux下查看本机路由,路由跟踪命令,,trace路由信息,静态路由添加原理!tracert超时原因等。

去试试:

➜  testGit route print
route: bad keyword: print

所以去搜:

route print

没找到有用的。

搜:

mac 查看本机路由

参考:

Mac OSX网络诊断命令 – Vamei – 博客园

试试:

netstat -nr

对方的:

brancepengdeMacBook-Pro:~ minglong$ netstat -nr
Routing tables
Internet:
Destination        Gateway            Flags        Refs      Use   Netif Expire
default            192.168.1.1        UGSc          410        0     en0
127                127.0.0.1          UCS             1        0     lo0
127.0.0.1          127.0.0.1          UH             42    21837     lo0
169.254            link#4             UCS             1        0     en0
192.168.1          link#4             UCS             4        0     en0
192.168.1.1/32     link#4             UCS             2        0     en0
192.168.1.1        88:25:93:a3:1f:9d  UHLWIir       412      752     en0   1192
192.168.1.112      link#4             UHLWIi          1        0     en0
192.168.1.113/32   link#4             UCS             2        0     en0
192.168.1.113      f4:5c:89:92:a:9b   UHLWIi          1        1     lo0
192.168.1.114      link#4             UHLWIi          1        0     en0
192.168.1.255      link#4             UHLWbI          1       55     en0
224.0.0            link#4             UmCS            2        0     en0
224.0.0.251        1:0:5e:0:0:fb      UHmLWI          1        0     en0
255.255.255.255/32 link#4             UCS             1        0     en0
Internet6:
Destination                             Gateway                         Flags         Netif Expire
::1                                     ::1                             UHL             lo0
fe80::%lo0/64                           fe80::1%lo0                     UcI             lo0
fe80::1%lo0                             link#1                          UHLI            lo0
fe80::%en0/64                           link#4                          UCI             en0
fe80::f65c:89ff:fe92:a9b%en0            f4:5c:89:92:a:9b                UHLI            lo0
fe80::%awdl0/64                         link#9                          UCI           awdl0
fe80::2cad:9cff:fec8:9db8%awdl0         2e:ad:9c:c8:9d:b8               UHLI            lo0
ff01::%lo0/32                           ::1                             UmCI            lo0
ff01::%en0/32                           link#4                          UmCI            en0
ff01::%awdl0/32                         link#9                          UmCI          awdl0
ff02::%lo0/32                           ::1                             UmCI            lo0
ff02::%en0/32                           link#4                          UmCI            en0
ff02::%awdl0/32                         link#9                          UmCI          awdl0
brancepengdeMacBook-Pro:~ minglong$

我的:

➜  testGit netstat -nr
Routing tables
Internet:
Destination        Gateway            Flags        Refs      Use   Netif Expire
default            192.168.1.1        UGSc          442        0     en0
127                127.0.0.1          UCS             1        0     lo0
127.0.0.1          127.0.0.1          UH             21  1323780     lo0
192.168.1          link#4             UCS             3        0     en0
192.168.1.1/32     link#4             UCS             2        0     en0
192.168.1.1        88:25:93:a3:1f:9d  UHLWIir       445      810     en0   1189
192.168.1.112      link#4             UHLWIi          1        0     en0
192.168.1.114/32   link#4             UCS             1        0     en0
192.168.1.255      link#4             UHLWbI          1       55     en0
224.0.0/4          link#4             UmCS            3        0     en0
224.0.0.251        1:0:5e:0:0:fb      UHmLWI          1        0     en0
239.255.255.250    1:0:5e:7f:ff:fa    UHmLWI          1      180     en0
255.255.255.255/32 link#4             UCS             1        0     en0
Internet6:
Destination                             Gateway                         Flags         Netif Expire
default                                 fe80::%utun0                    UGcI          utun0
default                                 fe80::%utun1                    UGcI          utun1
::1                                     ::1                             UHL             lo0
fe80::%lo0/64                           fe80::1%lo0                     UcI             lo0
fe80::1%lo0                             link#1                          UHLI            lo0
fe80::%en0/64                           link#4                          UCI             en0
fe80::89d:5699:d846:3190%en0            ac:bc:32:7f:1:1                 UHLI            lo0
fe80::%awdl0/64                         link#8                          UCI           awdl0
fe80::306d:7aff:fec8:132b%awdl0         32:6d:7a:c8:13:2b               UHLI            lo0
fe80::%utun0/64                         fe80::7296:2a00:4723:808%utun0  UcI           utun0
fe80::7296:2a00:4723:808%utun0          link#10                         UHLI            lo0
fe80::%utun1/64                         fe80::65be:dd4c:bbb2:4f3a%utun1 UcI           utun1
fe80::65be:dd4c:bbb2:4f3a%utun1         link#11                         UHLI            lo0
ff01::%lo0/32                           ::1                             UmCI            lo0
ff01::%en0/32                           link#4                          UmCI            en0
ff01::%awdl0/32                         link#8                          UmCI          awdl0
ff01::%utun0/32                         fe80::7296:2a00:4723:808%utun0  UmCI          utun0
ff01::%utun1/32                         fe80::65be:dd4c:bbb2:4f3a%utun1 UmCI          utun1
ff02::%lo0/32                           ::1                             UmCI            lo0
ff02::%en0/32                           link#4                          UmCI            en0
ff02::%awdl0/32                         link#8                          UmCI          awdl0
ff02::%utun0/32                         fe80::7296:2a00:4723:808%utun0  UmCI          utun0
ff02::%utun1/32                         fe80::65be:dd4c:bbb2:4f3a%utun1 UmCI          utun1

Git over HTTPS

我这里空的:

➜  testGit git config http.proxy
➜  testGit git config https.proxy

对方是有值的,之前设置的值:

brancepengdeMacBook-Pro:~ minglong$ git config https.proxy
127.0.0.1:1080
brancepengdeMacBook-Pro:~ minglong$ git config https.proxy ""
fatal: not in a git directory

git https.proxy

git 设置和取消代理 · GitHub

git config –global –unset https.proxy
git config –global https.proxy ‘socks5://127.0.0.1:1080’

我的:

➜  testGit git config –global –unset http.proxy

error: invalid key: http.proxy

➜  testGit git config –global –unset https.proxy

对方的:

brancepengdeMacBook-Pro:~ minglong$ git config –global –unset http.proxy

error: invalid key: http.proxy

brancepengdeMacBook-Pro:~ minglong$ git config –global –unset https.proxy
brancepengdeMacBook-Pro:~ minglong$

如何为 Git 设置代理? – SegmentFault

如何让 Git 使用 HTTP 代理服务器 | vpsee.com

最后是:

百度搜的帖子,把github的host删了:

 就可以连接github了

然后后续的Carthage update也就可以工作了:

【总结】

出问题的Mac是,之前不知道谁去给hosts中添加了配置,去掉无用的配置,即可正常访问github.com,即可git clone,即可carthage update了。

转载请注明:在路上 » 【已解决】git clone出错:Failed to connect to github.com port 443 Operation timed out

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (2)

  1. 去掉hosts的内容还是不行。
    York3年前 (2021-03-17)回复
  2. 说的好细致,很棒
    73年前 (2021-03-05)回复
88 queries in 0.170 seconds, using 22.19MB memory