解决 Git 克隆或推送时出现 "unable to access" 和 "port 443" 连接失败的问题,通过配置 HTTP/SOCKS 代理让 Git 正常访问 GitHub。

Git 连接 GitHub 报错 443 的解决方法
1 mins
213 words
Loading views

问题描述h2

在使用 Git 克隆项目时,出现以下报错:

fatal: unable to access 'https://github.com/xxx/xxx.git':
Failed to connect to github.com port 443: Connection refused

这个问题通常是因为代理设置不正确导致的,需要为 Git 配置正确的代理。

解决方案h2

方法一:设置 HTTP 代理h3

端口号与你使用的代理软件有关,常见端口如下:

代理软件默认端口
Clash7890
Clash Verge7897
v2rayN10808
SSR1080

以 Clash Verge(端口 7897)为例:

Terminal window
git config --global http.proxy http://127.0.0.1:7897
git config --global https.proxy http://127.0.0.1:7897

方法二:设置 SOCKS5 代理h3

如果 HTTP 代理不生效,可以尝试 SOCKS5 代理:

Terminal window
git config --global http.proxy socks5://127.0.0.1:7897
git config --global https.proxy socks5://127.0.0.1:7897

验证配置h2

检查代理是否设置成功:

Terminal window
git config --global --list

配置中出现 http.proxyhttps.proxy 则代表设置成功:

取消代理h2

如果需要取消代理设置:

Terminal window
git config --global --unset http.proxy
git config --global --unset https.proxy

评论