解决终端无法访问github.com 的错误

错误情况

  1. pac文件中已经添加域名,浏览器可以访问github.com,但终端ping不通。
  2. 使用yarn install 安装依赖,一直遇到 fatal: unable to access 'https://github.com/protobuf.js/': LibreSSL SSL_read: Operation timed out, errno 60 的错误。
  3. 使用 git clone https://github.com/protobuf.js.git 可以拉取仓库。

解决办法

  1. 搜索github.com 的IP地址, 网址 Hostname to IP Address.
  2. 发现IP是 140.82.112.4, 且可以ping通。
  3. 将这个IP加入host文件, sudo vi /etc/hosts
  4. 再次 ping github.com, 成功

解决办法2

  1. 直接从你的代理软件中选择 Copy HTTP Proxy Shell Export Line
  2. 在终端中黏贴: export http_proxy="http://127.0.0.1:8001"; export HTTP_PROXY="http://127.0.0.1:8001"; export https_proxy="http://127.0.0.1:8001"; export HTTPS_PROXY="http://127.0.0.1:8001"
posted @ 2021-12-08 11:23  略略略——  阅读(3891)  评论(0编辑  收藏  举报