flutter pub get 时出现报错: Failed to connect to github.com port 443 after 75004 ms: Couldn't connect to server

  最近在执行 flutter pub get 拉取 flutter 工程依赖时,一直访问不了 github,报错这个

Running "flutter pub get" in hlm_flutter...
Resolving dependencies...
Git error. Command: `git fetch`
stdout:
stderr: fatal: unable to access 'https://github.com/alibaba/flutter_boost.git/': Failed to connect to github.com port 443 after 75004 ms: Couldn't connect to server
exit code: 128
pub get failed

  修改了/private/etc 目录下  hosts 文件也不见起效。

  开启网络代理梯子后 github 网站可以正常打开,但是执行 flutter pub get 还是一直报这个错,最后的解决方案是:

  配置代理:

git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy http://127.0.0.1:7890

  执行 flutter pub get

  成功后再关闭这个代理

git config --global --unset http.proxy
git config --global --unset https.proxy

 

posted @ 2025-01-02 18:25  ZachRobin  阅读(619)  评论(0)    收藏  举报