[GitHub] fatal: unable to access 'https://github.com/': Failed to connect to github.com port 443: Operation timed out
解决Github连接错误的思路
由于众所周知的缘故,连接到github越来越微妙,分享一些MAC平台上的解决思路,希望对你有帮助:
最新方案(2023年11月)
超级好用的命令行走代理方式:
HTTPS_PROXY=”socks5://127.0.0.1:7890” git clone https://github.com/rustdesk/rustdesk
然后结合Clash For Window的 url-test 模式,选用最快的服务器;测试结果很满意:
HTTPS_PROXY=”socks5://127.0.0.1:7890” git clone https://github.com/rustdesk/rustdesk
Cloning into ‘rustdesk’…
remote: Enumerating objects: 59934, done.
remote: Counting objects: 100% (14388/14388), done.
remote: Compressing objects: 100% (326/326), done.
remote: Total 59934 (delta 14161), reused 14065 (delta 14062), pack-reused 45546
Receiving objects: 100% (59934/59934), 40.41 MiB | 956.00 KiB/s, done.
Resolving deltas: 100% (45272/45272), done.
单线程下载,平均速度达到1M/s左右;挺满意了
Errors
- fatal: unable to access ‘https://github.com/‘: Failed to connect to github.com port 443: Operation timed out
- fatal: Authentication failed for ‘https://github.com/‘
- fatal unable to access https://github.com LibreSSL SSL_connect SSL_ERROR_SYSCALL in connection to github.com 443
Notes:
Don’t verify the operation in editor(WebStorm,IntelliJ IDEA…etc), use command(Mac’s terminal.app), use terminal.app
Solutions for: Operation timed out
- Fix the hosts to make sure the ssh connection between your Computer and github.com is availble(修复连接到github.com)
Verify Standard 判断标准:$ ssh -T git@github.com
1.1 记录下github的IP地址, 把IP Address 记录下来
打开https://github.com.ipaddress.com/
打开https://fastly.net.ipaddress.com/github.global.ssl.fastly.net#ipinfo
打开https://github.com.ipaddress.com/assets-cdn.github.com
1.2 打开电脑的hosts文件(/private/etc/hosts),把下列的地址对应写入,然后保存即可(version2021.11.23)
# Github Start. Updated 20211123/CZ 140.82.113.3 github.com 199.232.69.194 github.global.ssl.fastly.net 185.199.108.153 assets-cdn.github.com 185.199.109.153 assets-cdn.github.com 185.199.110.153 assets-cdn.github.com 185.199.111.153 assets-cdn.github.com
Github End
1.3 在终端在输以下指令刷新DNS(需要权限)
1 | sudo killall -HUP mDNSResponder |
1.4 如果之前用ssh proxy,取消它
1 | git config --global http.proxy http://127.0.0.1:1080 |
1.5 重新尝试 ping github.com. 重新尝试 ssh -T git@github.com
新的错误可能和授权有关,至少证明连接到github.com是通的。
Solutions for: Authentication
- Create new Token and login to github.com (新建密钥并登陆进github.com)
Verify Standard 判断标准:$ git pull
2.1 Creating a personal access token at https://github.com/settings/tokens
授权_admin:org, admin:public_key, admin:repo_hook, gist, read:user, repo, write:packages_
2.2 Terminal.app 命令行,运行 git pull(先要cd 到原来的git 根目录)
Username for ‘https://github.com‘: (这个地方输入登录github网址用的用户名,我的是用9个英文字母)
Password for ‘https://***@github.com’: (这个地方要是输入#2.1中得到的Token)
2.3 判断一下连接和授权,如果需要ssh连接,继续添加配置以下。
2.4 生成ssh密钥。Generating a new SSH key and adding it to the ssh-agent。具体步骤简要如下:
1 | $ ssh-keygen -t ed25519 -C "your\_email@example.com" |
2.5 协助排查:github服务端的日志,显示有用的连接信息,用来验证链路是否握手成功等等
https://github.com/settings/security-log
尽量把验证都放在命令行中,这样更高效直接(在IDE中操作,在验证太费劲了),terminal成功以后,IDEA会自动也成功,因为它们分享相同的配置(git 根目录下面有.git的配置目录)
参见文档:
https://juejin.cn/post/6844904193170341896
https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/
Node.js也被同样错误卡
hexo d
…
fatal: unable to access ‘https://github.com/@@@@@.git/‘: LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
FATAL Something’s wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
…
1 | git config --global http.proxy http://127.0.0.1:7890 |
重试hexo d
1 | git config --global --unset http.proxy |
重试hexo d
有的时候很奇怪:非要先proxy以后重试失败,然后在这样–unset以后重试,就能成功。
具体错误内容
fatal: unable to access ‘https://github.com/@@@@@@.git/‘: LibreSSL SSL_connect: Connection reset by peer in connection to github.com:443
解决办法后来是因为hexo没有检测到内容变动,不去push。
hexo clean
然后在 hexo g && hexo d 就解决了
hexo d 更新的解决办法
运行命令行当时输入:
1 | HTTPS_PROXY="socks5://127.0.0.1:7890" hexo g && hexo d |
这样省去了来回切换的麻烦步骤。
1 | rewrite api/site.json (74%) |
持续问题这个错误,排查了网络连接到github也正常的。(由于另外一个窗口已经hexo g && hexo s) 后来发现是命令要简化成:
HTTPS_PROXY=”socks5://127.0.0.1:7890” hexo d
思路:当Github源连同账号被删除后
缓存,当Github源连同账号被删除后,用CDN可以继续访问到
比如:1
2
3
4【已失效用下面的CDN缓存替换】curl -fksSL https://github.com/lmq8267/567/releases/download/scriptfile/install1.10.3.sh | sh
发现一个CDN的优点:当缓存完成后源站点内容被删除,CDN还是会保存着内容;也就是说这个同步是单方向的。
curl -fkSL https://fastly.jsdelivr.net/gh/lmq8267/ZeroTierOne@master/install/installzero.sh | sh还有一个思路:hub.docker.com
docker部署的缓存,仍然可以在一段时间内有效
比如:https://hub.docker.com/r/dreamacro/clash
ghproxy.com待更新
主域名 ghproxy.com 已喜提 GFW,已启用镜像站 mirror.ghproxy.com
hexo d 的 RPC failed 错误
具体信息错误如下:
error: RPC failed; HTTP 400 curl 22 The requested URL returned error: 400
send-pack: unexpected disconnect while reading sideband packet
fatal: the remote end hung up unexpectedly
解决办法:
确保本地的7890(或正在使用的)相关服务是正常且是可用的状态
- 比如浏览器的代理设置为这个本地的地址
单独再次运行
HTTPS_PROXY=”socks5://127.0.0.1:7890” hexo d