无法连接GitHub问题排查

项目场景:

无法连接GitHub


问题描述

在个人电脑上使用 Git 命令来操作 GitHub 上的项目,本来都很正常,突然某一天开始,会提示如下错误
ssh: connect to host github.com port 22: Connection refused。

ssh: connect to host github.com port 22: Connection refused
fatal: Could not read from remote repository.
​
Please make sure you have the correct access rights
and the repository exists.

原因分析:

ssh: connect to host github.com port 22: Connection refused这个错误提示的是连接 github.com 的 22 端口被拒绝了。

原本以为 http://github.com 挂了,但是浏览器访问 GitHub Status 一切正常。
在这里插入图片描述

解决方案:

使用命令验证连接情况:

ssh -vT git@github.com
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to github.com [::1] port 22.
debug1: connect to address ::1 port 22: Connection refused
debug1: Connecting to github.com [127.0.0.1] port 22.
debug1: connect to address 127.0.0.1 port 22: Connection refused
ssh: connect to host github.com port 22: Connection refused

我发现连接地址居然是 ::1,

到这里问题就很明确了,是 DNS 解析出问题了,导致 http://github.com 域名被解析成了 localhost 的 ip 地址,就自然连不上 GitHub 了。

这个问题就是 DNS 解析被污染了,有 2 种可能:

DNS 解析被运营商劫持了
使用了科学上网工具
打开本地 Host 文件 加一条域名映射搞定

140.82.113.4 github.com
  • 7
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值