Failed to connect to github.com port 443 after 21150 ms: Could not connect to server

什么是443端口号?
443端口是互联网上所有加密通信的通用端口,也是HTTPS所使用的端口号。 HTTP 协议使用的是80端口处理所有入站和出站信息。但问题是 HTTP 协议不安全,因为所有数据都以纯文本形式从一台计算机传输到另一台计算机。

你的梯子使用的是什么端口号?
我的梯子是通过本地127.0.0.1:7890向代理服务器发送请求。也就是说,我如果想用梯子,我就得用7890端口向外部请求网络服务。


问题:
一般你用梯子设置代理ip端口之后,浏览器就会使用你设置的ip端口。但是git他却没有使用代理端口7890给我传东西,而是继续使用默认的443告诉我超时。
解决:
我们需要设置git的代理端口也为7890.

1
2
3
4
5
6
7
8
9
10
11
12
13
## 方法1(不推荐):全局设置,针对所有的git访问网址都代理
#使用http代理
git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy https://127.0.0.1:7890
#使用socks5代理
git config --global http.proxy socks5://127.0.0.1:7890
git config --global https.proxy socks5://127.0.0.1:7890

##方法2(推荐):只对github代理,github只是用http
#使用socks5代理(推荐)
git config --global http.https://github.com.proxy socks5://127.0.0.1:7890
#使用http代理(不推荐)
git config --global http.https://github.com.proxy http://127.0.0.1:7890

查询代理:

1
git config --global -l

取消代理:

1
2
git config --global --unset http.proxy 
git config --global --unset https.proxy