You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GCP认证异常:无法列出项目、设置项目及Node.js应用报错求助

GCP认证异常:无法列出项目、设置项目及Node.js应用报错求助

大家好,我最近碰到了一个头疼的GCP认证问题,折腾了好一阵都没搞定,想请各位帮忙分析分析!

之前我已经完成了GCP的认证,Node.js应用也能正常运行,但今天突然开始报错,错误信息里提到了google-gax,具体报错内容如下:

2023-09-07T18:13:41: Error: 13 INTERNAL: Received RST_STREAM with code 0

2023-09-07T18:13:41:     at callErrorFromStatus (/path/to/app/node_modules/.pnpm/@grpc+grpc-js@1.8.21/node_modules/@grpc/grpc-js/build/src/call.js:31:19)

2023-09-07T18:13:41:     at Object.onReceiveStatus (/path/to/app/node_modules/.pnpm/@grpc+grpc-js@1.8.21/node_modules/@grpc/grpc-js/build/src/client.js:192:76)

2023-09-07T18:13:41:     at Object.onReceiveStatus (/path/to/app/node_modules/.pnpm/@grpc+grpc-js@1.8.21/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:360:141)

2023-09-07T18:13:41:     at Object.onReceiveStatus (/path/to/app/node_modules/.pnpm/@grpc+grpc-js@1.8.21/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:323:181)

2023-09-07T18:13:41:     at /path/to/app/node_modules/.pnpm/@grpc+grpc-js@1.8.21/node_modules/@grpc/grpc-js/build/src/resolving-call.js:94:78

2023-09-07T18:13:41:     at process.processTicksAndRejections (node:internal/process/task_queues:77:11)

2023-09-07T18:13:41: for call at

2023-09-07T18:13:41:     at ServiceClientImpl.makeUnaryRequest (/path/to/app/node_modules/.pnpm/@grpc+grpc-js@1.8.21/node_modules/@grpc/grpc-js/build/src/client.js:160:32)

2023-09-07T18:13:41:     at ServiceClientImpl.<anonymous> (/path/to/app/node_modules/.pnpm/@grpc+grpc-js@1.8.21/node_modules/@grpc/grpc-js/build/src/make-client.js:105:19)

2023-09-07T18:13:41:     at /path/to/app/node_modules/.pnpm/@google-cloud+kms@3.8.0/node_modules/@google-cloud/kms/build/src/v1/key_management_service_client.js:241:29

2023-09-07T18:13:41:     at /path/to/app/node_modules/.pnpm/google-gax@3.6.1/node_modules/google-gax/build/src/normalCalls/timeout.js:44:16

2023-09-07T18:13:41:     at repeat (/path/to/app/node_modules/.pnpm/google-gax@3.6.1/node_modules/google-gax/build/src/normalCalls/retries.js:80:25)

2023-09-07T18:13:41:     at /path/to/app/node_modules/.pnpm/google-gax@3.6.1/node_modules/google-gax/build/src/normalCalls/retries.js:118:13

2023-09-07T18:13:41:     at OngoingCallPromise.call (/path/to/app/node_modules/.pnpm/google-gax@3.6.1/node_modules/google-gax/build/src/call.js:67:27)

2023-09-07T18:13:41:     at NormalApiCaller.call (/path/to/app/node_modules/.pnpm/google-gax@3.6.1/node_modules/google-gax/build/src/normalCalls/normalApiCaller.js:34:19)

2023-09-07T18:13:41:     at /path/to/app/node_modules/.pnpm/google-gax@3.6.1/node_modules/google-gax/build/src/createApiCall.js:84:30 {

2023-09-07T18:13:41:   code: 13,

2023-09-07T18:13:41:   details: 'Received RST_STREAM with code 0',

2023-09-07T18:13:41:   metadata: Metadata { internalRepr: Map(0) {}, options: {} },

2023-09-07T18:13:41:   note: 'Exception occurred in retry method that was not classified as transient'

2023-09-07T18:13:41: }

我执行gcloud auth list后,返回No credentialed accounts.,所以猜测是认证信息被移除或者过期了。

于是我删除了~/.config/gcloud目录,重新执行认证:

$ gcloud auth login

按照提示在浏览器里完成授权后,显示登录成功:

You are now logged in as [my_email@gmail.com].
Your current project is [None].  You can change this setting by running:
$ gcloud config set project PROJECT_ID

再次执行gcloud auth list,也显示已经有认证账号了:

Credentialed Accounts

ACTIVE  ACCOUNT

*       my_email@gmail.com

To set the active account, run:
$ gcloud config set account `ACCOUNT`

但问题来了,我无法列出项目,执行gcloud projects list时返回403错误:

ERROR: (gcloud.projects.list) HTTPError 403: <!DOCTYPE html>

<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
<title>Error 403 (Forbidden)!!1</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
</style>
<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
<p><b>403.</b> <ins>That’s an error.</ins>
<p>Your client does not have permission to get URL <code>/v1/projects</code> from this server.  <ins>That’s all we know.</ins>

如果我手动设置项目ID:

$ gcloud config set project my_project_id

会收到警告:

WARNING: You do not appear to have access to project [my_project_id] or it does not exist.
Are you sure you wish to set property [core/project] to my_project_id?
Do you want to continue (Y/n)?  y
Updated property [core/project].

确认设置后,我的Node.js应用又报出新错误:

Error: Could not load the default credentials.

奇怪的是,用同一个账号在另一台电脑上登录,执行gcloud projects list完全正常,能列出所有项目:

PROJECT_ID                 NAME       PROJECT_NUMBER
aaa                        aaa        123456789012
bbb                        bbb        123456789012
ccc                        ccc        123456789012
ddd                        ddd        123456789012
eee                        eee        123456789012
fff                        fff        123456789012
ggg                        ggg        123456789012
hhh                        hhh        123456789012

我已经尝试过以下方法,但都没解决问题:

  • 更新gcloud到最新版本
  • 创建新的系统用户尝试
  • 关闭防火墙
  • 禁用apparmor

有没有朋友遇到过类似的情况?或者能给我一些排查方向吗?非常感谢!

备注:内容来源于stack exchange,提问作者Mike

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.21 14:09:31