Google Cloud SDK初始化遇网络连接问题,可正常访问Google/GAE
我来帮你排查这个gcloud init的网络问题——既然浏览器能正常访问Google和GAE,那大概率是SDK的网络配置和浏览器不一致导致的,试试下面这些方案:
优先尝试跳过诊断直接初始化
你已经看到提示可以用gcloud init --skip-diagnostics,直接运行这个命令就能跳过网络诊断步骤,直接进入配置流程。很多时候诊断模块的检测逻辑和实际网络访问逻辑有差异,跳过它就能正常完成初始化。检查并同步代理配置
浏览器能访问Google,大概率是用了代理,但gcloud SDK默认不会继承系统或浏览器的代理设置,需要手动配置:- 先查看当前代理配置:
gcloud config list proxy - 如果没有配置,根据你的浏览器代理信息设置:
gcloud config set proxy/type http gcloud config set proxy/address 你的代理地址(比如127.0.0.1) gcloud config set proxy/port 代理端口(比如1080) - 如果代理需要用户名密码,补充设置:
gcloud config set proxy/username 你的代理用户名 gcloud config set proxy/password 你的代理密码 - 最后添加本地地址绕过代理,避免影响本地服务:
gcloud config set proxy/no_proxy localhost,127.0.0.1,::1
- 先查看当前代理配置:
切换到默认配置重新初始化
你之前选择重新初始化配置[a],可能这个配置残留了错误的网络设置,试试选选项3切换到default配置重新初始化:
运行gcloud init,当出现配置选择时输入3,跟着引导完成初始化。更新Google Cloud SDK到最新版本
旧版本的SDK可能存在网络兼容性问题,尝试更新:gcloud components update
如果更新也遇到网络问题,可以直接手动下载最新版本的SDK覆盖现有安装目录。
你的报错信息如下:
Pick configuration to use:
[1] Re-initialize this configuration [a] with new settings
[2] Create a new configuration
[3] Switch to and re-initialize existing configuration: [default]
Please enter your numeric choice: 1
Your current configuration has been set to: [a]
You can skip diagnostics next time by using the following flag: gcloud init --skip-diagnostics
Network diagnost...
内容的提问来源于stack exchange,提问作者Xue Guo




