git报错:ssh connect to host github.com port 22 Connection timed out

git报错:ssh: connect to host github.com port 22: Connection timed out fatal: Could not read from remote……

报错

> git pull --tags origin main
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

分析

登录了一下github网站,发现可以访问:

但是,ping了一下github,发现请求超时。

git、命令行都无法正确解析域名,但浏览器可以,有些奇怪。

但可以判断,确实是网络域名解析出现了问题,下面将采用手动修改hosts文件的方式解决。

解决

  1. 打开网站: https://www.ipaddress.com/ip-lookup,并在红框中输入域名,查询域名对应的IP地址;
  2. 点击lookup;
  • 得到对应区域的github主机名; img
  1. 查询如下两个主机名:
140.82.113.3 github.com
146.75.77.194 github.global.ssl.fastly.net
  1. 补充到C:\Windows\System32\drivers\etc\hosts文件的末尾,该文件不可编辑,可以复制到桌面,然后再复制回去实现替换。
  2. 测试结果:

声明: 本文转载自 ssh: connect to host github.com port 22: Connection timed out fatal: Could not read from remote……-优快云博客 ,版权归原作者所有。如有侵权,请联系删除。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值