Failed to connect to github.com port 443 after 21s
问题现象
- 使用 Git 推送到 GitHub 时,报超时:22/443 端口连接失败
产生原因
- 本机安装了“代理工具”,但该工具只对部分应用生效,Git 未走代理。
- 当前网络出口对直连 22/443 的质量较差或有限制,导致 Git 直连超时。
解决方案
- 让 Git 显式使用本机的“HTTP 代理端口”(在系统“代理设置”里可见,如 127.0.0.1:33210):
git config --global https.proxy http://127.0.0.1:33210git config --global http.proxy http://127.0.0.1:33210git ls-remote https://github.com/<user>/<repo>.git # 验证连通git push -u origin main # 正常推送
如不再需要,可恢复:
git config --global --unset https.proxygit config --global --unset http.proxy
一句话原理
- 将 Git 的流量经由本机“代理端口”转发,绕开对直连出口的限制,提升连通稳定性与成功率。