问题现象
在 WSL 或 Windows 中访问 GitHub 时出现 TLS 错误。
为了排除”WSL 没有连接 Windows 网络”的可能,在两边分别测试:
1curl -I https://github.com # WSL2curl.exe -I https://github.com # Windows两边均报错,说明问题不在 WSL 网络隔离,而是更上层的原因。
报错信息:
1gnutls_handshake() failed: The TLS connection was non-properly terminated问题原因
该问题通常不是 Git 或 WSL 的配置错误,而是代理节点异常导致 TLS 握手失败。
典型特征:
ping google.com返回198.18.x.x,说明代理已开启,Windows 梯子也在工作curl https://github.com失败- 浏览器可能可以访问,但命令行工具失败
原因:当前代理节点可以建立连接,但无法完成 TLS 握手,节点本身出了问题。
解决方案
在 Clash for Windows 中切换节点:
- 打开 Proxies
- 切换到 Developer(开发节点组)
- 更换一个节点(如 US / TW / Fast 等)
- 重新测试:
1curl -I https://github.com返回以下内容说明问题已解决:
1HTTP/2 200适用场景
适用于 WSL、Git、npm / pnpm、Docker、GitHub API、curl / wget 等命令行工具访问 GitHub 的场景。