Failed to connect to github.com port 443 after 78065 ms: Couldn't connect to server

转知乎的:
使用 git clone 下载 Github 等网站的仓库时,可能会遇到类似 "Recv failure: Connection was reset" 或 "Failed to connect to http://github.com port 443 after 21114 ms: Couldn't connect to server" 的报错。即使打开了全局代理,也会报错。此时,需要为 Git 单独配置代理,可以使用以下命令:

git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy http://127.0.0.1:7890

配置完成后,可以使用以下命令查看并修改 Git 的配置:

git config --global --edit

此时 Git 的默认编辑器会打开 ~/.gitconfig 文件,其中包括了代理的配置:

[http]
    proxy = http://127.0.0.1:7890
[https]
    proxy = http://127.0.0.1:7890

这样就完成了配置,可以 clone 一个仓库来测试,比如:

git clone https://github.com/github/gitignore.git

如果仍然报错,可以检查代理端口是否配置正确,并尝试用以下命令设置关闭 SSL 证书验证:

git config --global http.sslVerify false

关于 Git 配置的更多信息,请阅读 Git - git-config Documentation

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容