error request to xxx failed, reason: connect ECONNREFUSED 0.0.0.0:443

740 阅读1分钟

今天升级React-Native到0.70+报错,错误日志如下:

npx react-native upgrade 0.70.7                   
info Fetching diff between v0.69.7 and v0.70.7...
error request to https://raw.githubusercontent.com/react-native-community/rn-diff-purge/diffs/diffs/0.69.7..0.70.7.diff failed, reason: connect ECONNREFUSED 0.0.0.0:443
error Failed to fetch diff for react-native@0.70.7. Maybe it's not released yet?
info For available releases to diff see: https://github.com/react-native-community/rn-diff-purge#diff-table-full-table-here

倒腾了大半天,记录一下解决方案吧,希望能帮助到遇到同样问题的同学。

  • 导致错误的原因

找不到 raw.githubusercontent.com

  • 解决方案

通过 www.ipaddress.com/ 查询 raw.githubusercontent.com 的IP,并在hosts中配置

185.199.108.133 raw.githubusercontent.com
  • 补充说明
// 这个是我查询到的,我只添加了其中的一个IP,这些IP都是都是可以解析到「raw.githubusercontent.com」的
### What is raw.githubusercontent.com IP address?

raw.githubusercontent.com resolves to 4 IPv4 addresses and 4 IPv6 addresses:

-   **185.199.108.133**
-   **185.199.109.133**
-   **185.199.110.133**
-   **185.199.111.133**
-   **2606:50c0:8000::154**
-   **2606:50c0:8001::154**
-   **2606:50c0:8002::154**
-   **2606:50c0:8003::154**