21将您在终端中看到的消息与下面的部分相匹配。21将您在终端中看到的消息与下面的部分相匹配。
22 22
23| 消息 | 部分 |23| 消息 | 部分 |
24| :-------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------- |24| :-------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------- |
25| `API Error: 500 Internal server error` | [服务器错误](#api-error-500-internal-server-error) |25| `API Error: 500 Internal server error` | [服务器错误](#api-error-500-internal-server-error) |
26| `API Error: Repeated 529 Overloaded errors` | [服务器错误](#api-error-repeated-529-overloaded-errors) |26| `API Error: Repeated 529 Overloaded errors` | [服务器错误](#api-error-repeated-529-overloaded-errors) |
27| `Request timed out` | [服务器错误](#request-timed-out),或如果消息提到您的互联网连接,则为[网络](#unable-to-connect-to-api) |27| `Request timed out` | [服务器错误](#request-timed-out),或[网络](#unable-to-connect-to-api)(如果消息提到您的互联网连接) |
28| `Server error mid-response. The response above may be incomplete.` | [服务器错误](#the-response-above-may-be-incomplete) |
29| `Connection closed mid-response` / `Response stalled mid-stream` | [服务器错误](#the-response-above-may-be-incomplete) |
28| `<model> is temporarily unavailable, so auto mode cannot determine the safety of...` | [服务器错误](#auto-mode-cannot-determine-the-safety-of-an-action) |30| `<model> is temporarily unavailable, so auto mode cannot determine the safety of...` | [服务器错误](#auto-mode-cannot-determine-the-safety-of-an-action) |
29| `Auto mode could not evaluate this action and is blocking it for safety` | [服务器错误](#auto-mode-cannot-determine-the-safety-of-an-action) |31| `Auto mode could not evaluate this action and is blocking it for safety` | [服务器错误](#auto-mode-cannot-determine-the-safety-of-an-action) |
30| `Auto mode classifier transcript exceeded context window` | [服务器错误](#auto-mode-cannot-determine-the-safety-of-an-action) |32| `Auto mode classifier transcript exceeded context window` | [服务器错误](#auto-mode-cannot-determine-the-safety-of-an-action) |
33| `Agent terminated early due to an API error` | [服务器错误](#agent-terminated-early-due-to-an-api-error) |
31| `You've hit your session limit` / `You've hit your weekly limit` | [使用限制](#you%E2%80%99ve-hit-your-session-limit) |34| `You've hit your session limit` / `You've hit your weekly limit` | [使用限制](#you%E2%80%99ve-hit-your-session-limit) |
32| `Usage credits required for 1M context` | [使用限制](#usage-credits-required-for-1m-context) |35| `Usage credits required for 1M context` | [使用限制](#usage-credits-required-for-1m-context) |
33| `Server is temporarily limiting requests` | [使用限制](#server-is-temporarily-limiting-requests) |36| `Server is temporarily limiting requests` | [使用限制](#server-is-temporarily-limiting-requests) |
43| `Remote Control is only available when using Claude via api.anthropic.com` | [身份验证](#remote-control-requires-the-anthropic-api) |46| `Remote Control is only available when using Claude via api.anthropic.com` | [身份验证](#remote-control-requires-the-anthropic-api) |
44| `OAuth token revoked` / `OAuth token has expired` | [身份验证](#oauth-token-revoked-or-expired) |47| `OAuth token revoked` / `OAuth token has expired` | [身份验证](#oauth-token-revoked-or-expired) |
45| `does not meet scope requirement user:profile` | [身份验证](#oauth-scope-requirement) |48| `does not meet scope requirement user:profile` | [身份验证](#oauth-scope-requirement) |
49| `AWS credentials expired or invalid` | [身份验证](#aws-credentials-expired-or-invalid) |
50| `AWS authentication failed` | [身份验证](#aws-authentication-failed) |
46| `Unable to connect to API` | [网络](#unable-to-connect-to-api) |51| `Unable to connect to API` | [网络](#unable-to-connect-to-api) |
47| `Waiting for API response · will retry in` | [自动重试](#automatic-retries),或如果问题持续,则为[网络](#unable-to-connect-to-api) |52| `Waiting for API response · will retry in` | [自动重试](#automatic-retries),或[网络](#unable-to-connect-to-api)(如果问题持续) |
48| `SSL certificate verification failed` | [网络](#ssl-certificate-errors) |53| `SSL certificate verification failed` | [网络](#ssl-certificate-errors) |
54| `SSL certificate error (...)` during login or startup | [网络](#ssl-certificate-errors) |
49| `403` with `x-deny-reason: host_not_allowed` in a cloud or routine session | [网络](#host-not-allowed-in-a-cloud-session) |55| `403` with `x-deny-reason: host_not_allowed` in a cloud or routine session | [网络](#host-not-allowed-in-a-cloud-session) |
50| `Prompt is too long` | [请求错误](#prompt-is-too-long) |56| `Prompt is too long` | [请求错误](#prompt-is-too-long) |
51| `Error during compaction: Conversation too long` | [请求错误](#error-during-compaction-conversation-too-long) |57| `Error during compaction: Conversation too long` | [请求错误](#error-during-compaction-conversation-too-long) |
61| `max_tokens must be greater than thinking.budget_tokens` | [请求错误](#thinking-budget-exceeds-output-limit) |67| `max_tokens must be greater than thinking.budget_tokens` | [请求错误](#thinking-budget-exceeds-output-limit) |
62| `API Error: 400 due to tool use concurrency issues` | [请求错误](#tool-use-or-thinking-block-mismatch) |68| `API Error: 400 due to tool use concurrency issues` | [请求错误](#tool-use-or-thinking-block-mismatch) |
63| `Claude Code is unable to respond to this request, which appears to violate our Usage Policy` | [请求错误](#usage-policy-refusal) |69| `Claude Code is unable to respond to this request, which appears to violate our Usage Policy` | [请求错误](#usage-policy-refusal) |
70| `--bg and --print conflict` | [命令行错误](#command-line-errors) |
64| 响应质量似乎低于平常 | [响应质量](#responses-seem-lower-quality-than-usual) |71| 响应质量似乎低于平常 | [响应质量](#responses-seem-lower-quality-than-usual) |
65 72
66<h2 id="automatic-retries">73<h2 id="automatic-retries">
67 自动重试74 自动重试
68</h2>75</h2>
69 76
70Claude Code 在向您显示错误之前会重试瞬时故障。服务器错误、过载响应、请求超时、临时 429 限流和断开的连接都会以指数退避方式重试最多 10 次。重试时,微调器显示 `Retrying in Ns · attempt x/y` 倒计时。77Claude Code 在向您显示错误之前会重试瞬时故障。服务器错误、过载响应、请求超时、临时 429 限流和断开的连接都会以指数退避方式重试最多 10 次。{/* min-version: 2.1.198 */}从 v2.1.198 开始,这涵盖了在任何可见输出流出之前在响应中途断开的连接:Claude Code 使用相同的退避重新发出请求,轮次继续而不是停止并显示连接错误。{/* min-version: 2.1.199 */}从 v2.1.199 开始,不携带您计划配额标头的临时 429 限流在您使用 claude.ai 订阅登录时也会重试;早期版本仅对 API 密钥和企业登录重试它们。
78
79两个故障类别不会重试,因为重试无法成功:
80
81* {/* min-version: 2.1.199 */}从 v2.1.199 开始,TLS 证书验证失败(例如 TLS 检查代理、缺少 `NODE_EXTRA_CA_CERTS` 包或过期证书)在第一次尝试时失败,因此修复立即出现,而不是在完整重试预算之后。请参阅 [SSL 证书错误](#ssl-certificate-errors)。瞬时 TLS 条件(例如握手超时)仍然会重试。
82* {/* min-version: 2.1.199 */}从 v2.1.199 开始,在 Claude 已经流出可见输出后到达的服务器错误会保留部分响应并附加[不完整响应通知](#the-response-above-may-be-incomplete),而不是重试,因为重新运行请求可能会执行相同的工具两次。早期版本丢弃了部分输出并将轮次报告为错误。
83
84重试时,微调器在错误标签后显示 `Retrying in Ns · attempt x/y` 倒计时。标签命名了第一次尝试中您可以立即采取行动的特定原因:网络已关闭、TLS 握手失败或您达到了速率限制。对于其他错误,它最初读作 `API error`。{/* min-version: 2.1.198 */}从 v2.1.198 开始,它切换到第三次尝试中的特定原因,或当 `CLAUDE_CODE_MAX_RETRIES` 允许少于三次时在最后一次尝试;早期版本仅在最后一次尝试时切换。
85
86{/* min-version: 2.1.198 */}从 v2.1.198 开始,重试期间会抑制通常的微调器提示。一旦错误原因被揭示,如果故障是 529 过载,倒计时下方的行也会命名检查服务状态的位置:Anthropic API 上的 `status.claude.com`,或其他配置上的提供商或网关主机。
71 87
72{/* min-version: 2.1.185 */}如果在请求仍然待处理时,响应流上 20 秒内没有数据到达,微调器会显示 `Waiting for API response · will retry in … · check your network`,然后再进行任何重试。请求尚未失败:倒计时运行到 Claude Code 中止停滞连接并重试的点,因此一旦数据恢复或重试成功,横幅就会自动清除。从 v2.1.185 开始,阈值为 20 秒;早期版本在 10 秒后显示横幅,措辞不同。如果它在每次尝试时都重新出现,请将其视为[网络问题](#unable-to-connect-to-api)。88{/* min-version: 2.1.185 */}如果在请求仍然待处理时,响应流上 20 秒内没有数据到达,微调器会显示 `Waiting for API response · will retry in … · check your network`,然后再进行任何重试。请求尚未失败:倒计时运行到 Claude Code 中止停滞连接并重试的点,因此一旦数据恢复或重试成功,横幅就会自动清除。从 v2.1.185 开始,阈值为 20 秒;早期版本在 10 秒后显示横幅,措辞不同。如果它在每次尝试时都重新出现,请将其视为[网络问题](#unable-to-connect-to-api)。
73 89
74当您看到本页上的错误之一时,这些重试已经用尽。您可以使用这些环境变量调整行为:90当您看到本页上的错误之一时,这些重试已经用尽,除非它属于不会重试的类别,例如证书验证失败。您可以使用这些环境变量调整行为:
75 91
76| 变量 | 默认值 | 效果 |92| 变量 | 默认值 | 效果 |
77| :---------------------------------------------- | :----- | :-------------------------------------------------------------------------------------- |93| :---------------------------------------------- | :----- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
78| [`CLAUDE_CODE_MAX_RETRIES`](/zh-CN/env-vars) | 10 | 重试次数。{/* min-version: 2.1.186 */}从 v2.1.186 开始上限为 15。降低它以在脚本中更快地显示故障。 |94| [`CLAUDE_CODE_MAX_RETRIES`](/zh-CN/env-vars) | 10 | 重试次数。{/* min-version: 2.1.186 */}从 v2.1.186 开始上限为 15;{/* min-version: 2.1.199 */}从 v2.1.199 开始 `CLAUDE_CODE_RETRY_WATCHDOG` 提高默认值并移除上限。降低它以在脚本中更快地显示故障。 |
79| [`CLAUDE_CODE_RETRY_WATCHDOG`](/zh-CN/env-vars) | 未设置 | 在 CI 作业等无人值守会话中设置为 `1`,以无限期重试 `429` 和 `529` 容量错误,而不是在 `CLAUDE_CODE_MAX_RETRIES` 次尝试后失败。 |95| [`CLAUDE_CODE_RETRY_WATCHDOG`](/zh-CN/env-vars) | 未设置 | 在 CI 作业等无人值守会话中设置为 `1`,以无限期重试 `429` 和 `529` 容量错误,而不是在 `CLAUDE_CODE_MAX_RETRIES` 次尝试后失败。{/* min-version: 2.1.199 */}从 v2.1.199 开始,它也提高了其他瞬时错误(例如服务器错误、超时和断开的连接)的默认重试计数至 300,大约三小时的退避,如果您显式设置该变量,则移除 `CLAUDE_CODE_MAX_RETRIES` 的 15 上限。 |
80| [`API_TIMEOUT_MS`](/zh-CN/env-vars) | 600000 | 每个请求的超时时间(毫秒)。为慢速网络或代理提高它。 |96| [`API_TIMEOUT_MS`](/zh-CN/env-vars) | 600000 | 每个请求的超时时间(毫秒)。为慢速网络或代理提高它。 |
81 97
82<h2 id="server-errors">98<h2 id="server-errors">
115API Error: Repeated 529 Overloaded errors. The API is at capacity — this is usually temporary. Try again in a moment. If it persists, check https://status.claude.com.131API Error: Repeated 529 Overloaded errors. The API is at capacity — this is usually temporary. Try again in a moment. If it persists, check https://status.claude.com.
116```132```
117 133
118末尾的句子因提供商而异,方式与上面的 500 错误相同。529 不是您的使用限制,也不会计入您的配额。134末尾的句子因提供商而异,方式与上面的 500 错误相同。
135
136529 不是您的使用限制,也不会计入您的配额。
119 137
120**要做什么:**138**要做什么:**
121 139
142* 如果是慢速网络或代理导致的,请按照[自动重试](#automatic-retries)中的说明提高 `API_TIMEOUT_MS`160* 如果是慢速网络或代理导致的,请按照[自动重试](#automatic-retries)中的说明提高 `API_TIMEOUT_MS`
143* 如果超时频繁且您的网络状况良好,请参阅下面的[网络和连接错误](#network-and-connection-errors)161* 如果超时频繁且您的网络状况良好,请参阅下面的[网络和连接错误](#network-and-connection-errors)
144 162
163<h3 id="the-response-above-may-be-incomplete">
164 The response above may be incomplete
165</h3>
166
167流式响应在 Claude 已经产生可见输出后失败。重新发送请求可能会运行相同的工具调用两次,因此 Claude Code 保留已经流出的内容并附加此通知,而不是丢弃轮次。您看到的变体命名了原因:
168
169```text theme={null}
170API Error: Server error mid-response. The response above may be incomplete.
171API Error: Connection closed mid-response. The response above may be incomplete.
172API Error: Response stalled mid-stream. The response above may be incomplete.
173```
174
175* {/* min-version: 2.1.199 */}}`Server error mid-response`:流中途过载或 5xx 服务器错误。此变体需要 Claude Code v2.1.199 或更高版本;在此之前,该情况丢弃了部分输出并将整个轮次报告为错误。
176* `Connection closed mid-response`:连接断开。
177* `Response stalled mid-stream`:流停止发送数据。
178
179**要做什么:**
180
181* 阅读流出的响应。没有任何内容丢失,但最后的句子或工具调用可能缺失。
182* 回复 `continue` 以让 Claude 从停止的地方继续
183* 如果在任何可见输出之前出现相同的错误,Claude Code 会重试请求而不是完成它。请参阅[自动重试](#automatic-retries)。
184
145<h3 id="auto-mode-cannot-determine-the-safety-of-an-action">185<h3 id="auto-mode-cannot-determine-the-safety-of-an-action">
146 Auto mode cannot determine the safety of an action186 Auto mode cannot determine the safety of an action
147</h3>187</h3>
186* 在出现的提示中批准或拒绝该操作226* 在出现的提示中批准或拒绝该操作
187* 运行 `/compact` 以减少对话大小,以便后续操作再次适应分类器窗口227* 运行 `/compact` 以减少对话大小,以便后续操作再次适应分类器窗口
188 228
229<h3 id="agent-terminated-early-due-to-an-api-error">
230 Agent terminated early due to an API error
231</h3>
232
233{/* min-version: 2.1.199 */}[subagent](/zh-CN/sub-agents) 的 API 请求终止失败,例如因为达到了使用限制或服务器错误的重试用尽,所以 subagent 在完成其任务之前停止。此消息需要 Claude Code v2.1.199 或更高版本;在此之前,API 错误文本被返回给 Claude,就像它是 subagent 的结果一样。
234
235```text theme={null}
236Agent terminated early due to an API error: <error detail>
237```
238
239**要做什么:**
240
241* 将冒号后的错误详情与本页上的其他部分相匹配,例如[使用限制](#usage-limits)或[服务器错误](#server-errors),并按照该部分的步骤操作
242* 一旦底层错误清除,要求 Claude 重试任务或[恢复 subagent](/zh-CN/sub-agents#resume-subagents)
243
244当速率限制、过载或服务器错误中断已经产生输出的前台 subagent 时,Claude 会收到该部分输出标记为不完整,而不是此错误。请参阅 [subagent 中的 API 错误](/zh-CN/sub-agents#api-errors-in-subagents)。
245
189<h2 id="usage-limits">246<h2 id="usage-limits">
190 使用限制247 使用限制
191</h2>248</h2>
193这些错误意味着与您的帐户或计划相关的配额已达到。它们与影响所有人的[服务器错误](#server-errors)不同。250这些错误意味着与您的帐户或计划相关的配额已达到。它们与影响所有人的[服务器错误](#server-errors)不同。
194 251
195<h3 id="you’ve-hit-your-session-limit">252<h3 id="you’ve-hit-your-session-limit">
196 您已达到会话限制253 You've hit your session limit
197</h3>254</h3>
198 255
199订阅计划包括滚动使用额度。当它用完时,您会看到以下消息之一:256订阅计划包括滚动使用额度。当它用完时,您会看到以下消息之一:
216要在达到限制之前监视您的剩余额度,请将 `rate_limits` 字段添加到[自定义状态行](/zh-CN/statusline#rate-limit-usage),或在桌面应用中单击模型选择器旁边的[使用环](/zh-CN/desktop#check-usage)。273要在达到限制之前监视您的剩余额度,请将 `rate_limits` 字段添加到[自定义状态行](/zh-CN/statusline#rate-limit-usage),或在桌面应用中单击模型选择器旁边的[使用环](/zh-CN/desktop#check-usage)。
217 274
218<h3 id="usage-credits-required-for-1m-context">275<h3 id="usage-credits-required-for-1m-context">
219 1M 上下文所需的使用信用276 Usage credits required for 1M context
220</h3>277</h3>
221 278
222所选模型使用 1M 令牌扩展上下文窗口,而您的计划仅通过使用信用包含它。279所选模型使用 1M 令牌扩展上下文窗口,而您的计划仅通过使用信用包含它。
237* 要从模型选择器中完全删除 1M 变体,请设置 [`CLAUDE_CODE_DISABLE_1M_CONTEXT=1`](/zh-CN/env-vars)294* 要从模型选择器中完全删除 1M 变体,请设置 [`CLAUDE_CODE_DISABLE_1M_CONTEXT=1`](/zh-CN/env-vars)
238 295
239<h3 id="server-is-temporarily-limiting-requests">296<h3 id="server-is-temporarily-limiting-requests">
240 服务器暂时限制请求297 Server is temporarily limiting requests
241</h3>298</h3>
242 299
243API 应用了与您的计划配额无关的短期限流。300API 应用了与您的计划配额无关的短期限流。
246API Error: Server is temporarily limiting requests (not your usage limit)303API Error: Server is temporarily limiting requests (not your usage limit)
247```304```
248 305
249这在显示之前会[自动重试](#automatic-retries)。306Claude Code 通过缺少真实限制响应携带的统一配额标头来区分这些。{/* min-version: 2.1.199 */}从 v2.1.199 开始,这会在显示之前[自动重试](#automatic-retries),无论您如何进行身份验证。在早期版本上,使用 claude.ai 订阅登录的会话在第一次出现时失败轮次;仅 API 密钥和企业登录重试它。
250 307
251**要做什么:**308**要做什么:**
252 309
254* 如果持续存在,请检查 [status.claude.com](https://status.claude.com)311* 如果持续存在,请检查 [status.claude.com](https://status.claude.com)
255 312
256<h3 id="request-rejected-429">313<h3 id="request-rejected-429">
257 请求被拒绝 (429)314 Request rejected (429)
258</h3>315</h3>
259 316
260您已达到为您的 API 密钥、Amazon Bedrock 项目或 Google Vertex AI 项目配置的速率限制。317您已达到为您的 API 密钥、Amazon Bedrock 项目或 Google Vertex AI 项目配置的速率限制。
263API Error: Request rejected (429) · this may be a temporary capacity issue. If it persists, check https://status.claude.com.320API Error: Request rejected (429) · this may be a temporary capacity issue. If it persists, check https://status.claude.com.
264```321```
265 322
266尾部句子命名了检查服务健康的位置,并因提供商而异。Bedrock、Vertex AI 和 Foundry 配置命名该提供商的服务状态,而不是 Anthropic 状态页面。自定义 `ANTHROPIC_BASE_URL` 命名网关主机。323末尾的句子命名了检查服务健康的位置,并因提供商而异。Bedrock、Vertex AI 和 Foundry 配置命名该提供商的服务状态,而不是 Anthropic 状态页面。自定义 `ANTHROPIC_BASE_URL` 命名网关主机。
267 324
268**要做什么:**325**要做什么:**
269 326
273* 降低并发:降低 [`CLAUDE_CODE_MAX_TOOL_USE_CONCURRENCY`](/zh-CN/env-vars),避免运行许多并行子代理,或使用 `/model` 切换到较小的模型以进行高容量脚本运行330* 降低并发:降低 [`CLAUDE_CODE_MAX_TOOL_USE_CONCURRENCY`](/zh-CN/env-vars),避免运行许多并行子代理,或使用 `/model` 切换到较小的模型以进行高容量脚本运行
274 331
275<h3 id="credit-balance-is-too-low">332<h3 id="credit-balance-is-too-low">
276 信用余额过低333 Credit balance is too low
277</h3>334</h3>
278 335
279您的 Console 组织已用完预付信用。336您的 Console 组织已用完预付信用。
373 Your organization has disabled API key authentication430 Your organization has disabled API key authentication
374</h3>431</h3>
375 432
433{/* min-version: 2.1.169 */}}
376您的 Console 组织的管理员已关闭 API 密钥身份验证,因此 API 拒绝了 Claude Code 正在发送的密钥。`·` 之后的恢复提示因密钥的来源而异:434您的 Console 组织的管理员已关闭 API 密钥身份验证,因此 API 拒绝了 Claude Code 正在发送的密钥。`·` 之后的恢复提示因密钥的来源而异:
377 435
378```text theme={null}436```text theme={null}
402Your organization has disabled Claude subscription access for Claude Code · Use an Anthropic API key instead, or ask your admin to enable access460Your organization has disabled Claude subscription access for Claude Code · Use an Anthropic API key instead, or ask your admin to enable access
403```461```
404 462
405这是一个服务器端组织设置,因此无法从本地设置、环境变量或 CLI 标志覆盖。Agent SDK 和 `-p` 非交互模式将其显示为 `oauth_org_not_allowed` 错误代码。463这是一个服务器端组织设置,因此无法从本地设置、环境变量或 CLI 标志覆盖。
464
465Agent SDK 和 `-p` 非交互模式将其显示为 `oauth_org_not_allowed` 错误代码。
406 466
407**要做什么:**467**要做什么:**
408 468
477 537
478* 运行 `/login` 以使用当前范围铸造新令牌。您不需要先登出。538* 运行 `/login` 以使用当前范围铸造新令牌。您不需要先登出。
479 539
540<h3 id="aws-credentials-expired-or-invalid">
541 AWS credentials expired or invalid
542</h3>
543
544{/* min-version: 2.1.198 */}}此消息需要 Claude Code v2.1.198 或更高版本,仅当在您的设置文件中设置了 [`awsAuthRefresh`](/zh-CN/amazon-bedrock#advanced-credential-configuration) 时才出现。您的 AWS 会话令牌过期或被拒绝,Claude Code 已经运行的自动刷新没有产生 API 接受的凭证。它出现在来自 [Claude Platform on AWS](/zh-CN/claude-platform-on-aws) 或 [Mantle 端点](/zh-CN/amazon-bedrock#use-the-mantle-endpoint) 的 401,这是这些提供商报告过期安全令牌的方式。
545
546中间的操作提示命名了您的设置中的 `awsAuthRefresh` 命令,因此它会有所不同。稳定的部分是前导 `AWS credentials expired or invalid`:
547
548```text theme={null}
549AWS credentials expired or invalid · run /login and select "Claude Platform on AWS · refresh credentials", or run `aws sso login --profile myprofile` in another terminal · API Error: 401 ...
550```
551
552如果未配置 `awsAuthRefresh`,相同的 401 会显示通用 `Please run /login` 消息,该消息无法刷新 AWS 凭证。
553
554**要做什么:**
555
556* 在另一个终端中运行消息中命名的 `awsAuthRefresh` 命令(例如 `aws sso login --profile myprofile`)并完成浏览器登录,然后重试
557* 在交互式会话中,运行 `/login`,选择 **3rd-party platform**,然后在 **Using 3rd-party platforms** 下选择 **Claude Platform on AWS · refresh credentials** 以运行相同的命令而无需重新启动 Claude Code。有关设置,请参阅[配置 AWS 凭证](/zh-CN/claude-platform-on-aws#1-configure-aws-credentials)
558* 如果刷新命令成功后错误重复,请在同一 shell 和配置文件中使用 `aws sts get-caller-identity` 确认身份在 Claude Code 外部有效
559
560<h3 id="aws-authentication-failed">
561 AWS authentication failed
562</h3>
563
564{/* min-version: 2.1.198 */}}此消息需要 Claude Code v2.1.198 或更高版本,仅当在您的设置文件中设置了 [`awsAuthRefresh`](/zh-CN/amazon-bedrock#advanced-credential-configuration) 时才出现。您的 AWS 提供商返回了 403,或 [Amazon Bedrock](/zh-CN/amazon-bedrock) 返回了 401。
565
566Claude Code 无法判断您遇到了哪个原因。Amazon Bedrock 将过期的安全令牌报告为 403,但 403 也是它报告授权拒绝的方式,例如来自缺少 IAM 权限或未为您的帐户启用的模型的 `AccessDeniedException`。
567
568来自 Amazon Bedrock 的 401 也会落在这里,而不是在 [AWS credentials expired or invalid](#aws-credentials-expired-or-invalid) 下,因为 Bedrock 不将过期令牌报告为 401。来自该端点的 401 通常来自请求路径中的其他内容,例如公司代理。
569
570凭证刷新可以修复过期令牌,无法修复其他原因,因此消息提供两者:
571
572```text theme={null}
573AWS authentication failed · run /login and select "Claude Platform on AWS · refresh credentials", or run `aws sso login --profile myprofile` in another terminal · if credentials are current, check AWS permissions and model access · API Error: 403 ...
574```
575
576中间的操作提示命名了您的设置中的 `awsAuthRefresh` 命令,因此它会有所不同。稳定的部分是前导 `AWS authentication failed`。
577
578**要做什么:**
579
580* 运行消息中命名的 `awsAuthRefresh` 命令或 `aws sso login`,以防过期凭证是原因
581* 如果您的凭证是最新的,请确认 [IAM 配置](/zh-CN/amazon-bedrock#iam-configuration) 中的 IAM 权限已附加到您使用的身份,并且所选模型已为您的帐户和区域启用
582* 运行 `aws sts get-caller-identity` 以确认您的请求使用哪个身份;过时的 `AWS_PROFILE` 或默认配置文件是权限不匹配的常见原因
583
480<h2 id="network-and-connection-errors">584<h2 id="network-and-connection-errors">
481 网络和连接错误585 网络和连接错误
482</h2>586</h2>
525Unable to connect to API: Self-signed certificate detected629Unable to connect to API: Self-signed certificate detected
526```630```
527 631
632{/* min-version: 2.1.199 */}}从 v2.1.199 开始,证书验证失败不会重试,因此此错误出现在第一次尝试而不是在完整[重试预算](#automatic-retries)之后。早期版本在显示之前花费几分钟重试。瞬时 TLS 条件(例如握手超时)仍然会重试。
633
634在 `/login` 和启动连接检查期间,相同的失败会报告为 OpenSSL 代码和内联修复:
635
636```text theme={null}
637SSL certificate error (UNABLE_TO_GET_ISSUER_CERT_LOCALLY). If you are behind a corporate proxy or TLS-intercepting firewall, set NODE_EXTRA_CA_CERTS to your CA bundle path, or ask IT to allowlist *.anthropic.com. Run /doctor for details.
638```
639
528**要做什么:**640**要做什么:**
529 641
530* 导出您组织的 CA 包并使用 `NODE_EXTRA_CA_CERTS=/path/to/ca-bundle.pem` 指向 Claude Code642* 导出您组织的 CA 包并使用 `NODE_EXTRA_CA_CERTS=/path/to/ca-bundle.pem` 指向 Claude Code
627API Error: 400 ... image dimensions exceed max allowed size739API Error: 400 ... image dimensions exceed max allowed size
628```740```
629 741
630{/* min-version: 2.1.142 */}Claude Code 将无法处理的图像替换为文本占位符并重试,因此后续消息成功。在 2.1.142 之前的版本上,粘贴的图像可能保留在对话中,并在每个后续消息上重复相同的错误。要在这些版本上恢复,请按 Esc 两次并回退到添加图像的轮次之前。742{/* min-version: 2.1.142 */}}Claude Code 将无法处理的图像替换为文本占位符并重试,因此后续消息成功。在 2.1.142 之前的版本上,粘贴的图像可能保留在对话中,并在每个后续消息上重复相同的错误。要在这些版本上恢复,请按 Esc 两次并回退到添加图像的轮次之前。
631 743
632**要做什么:**744**要做什么:**
633 745
694 There's an issue with the selected model806 There's an issue with the selected model
695</h3>807</h3>
696 808
809{/* min-version: 2.1.160 */}}
697配置的模型名称未被识别或您的帐户缺少对它的访问权限。从 v2.1.160 开始,尾部提示(此处以其交互式形式显示)因表面而异。810配置的模型名称未被识别或您的帐户缺少对它的访问权限。从 v2.1.160 开始,尾部提示(此处以其交互式形式显示)因表面而异。
698 811
699```text theme={null}812```text theme={null}
729 Model is restricted by your organization's settings842 Model is restricted by your organization's settings
730</h3>843</h3>
731 844
732{/* min-version: 2.1.187 */}您的组织管理员已在 Claude 控制台中禁用此模型,或者它被托管设置中的 [`availableModels`](/zh-CN/model-config#restrict-model-selection) 允许列表排除。当使用 `--model`、`ANTHROPIC_MODEL` 或 `model` 设置设置受限制的模型时,Claude Code 会替换为允许的模型并继续。为受限制的模型键入 `/model <name>` 会被拒绝,显示 `Run /model to choose a different model.`,会话保持其当前模型。845{/* min-version: 2.1.187 */}}您的组织管理员已在 Claude 控制台中禁用此模型,或者它被托管设置中的 [`availableModels`](/zh-CN/model-config#restrict-model-selection) 允许列表排除。当使用 `--model`、`ANTHROPIC_MODEL` 或 `model` 设置设置受限制的模型时,Claude Code 会替换为允许的模型并继续。为受限制的模型键入 `/model <name>` 会被拒绝,显示 `Run /model to choose a different model.`,会话保持其当前模型。
733 846
734```text theme={null}847```text theme={null}
735Model "claude-opus-4-8" is restricted by your organization's settings. Using claude-sonnet-4-6 instead.848Model "claude-opus-4-8" is restricted by your organization's settings. Using claude-sonnet-4-6 instead.
753 866
754**要做什么:**867**要做什么:**
755 868
869{/* min-version: 2.1.197 */}}
870
756* 运行 `claude update` 并重新启动 Claude Code。Opus 4.7 需要 v2.1.111 或更高版本。Opus 4.8 需要 v2.1.154 或更高版本。Sonnet 5 需要 v2.1.197 或更高版本871* 运行 `claude update` 并重新启动 Claude Code。Opus 4.7 需要 v2.1.111 或更高版本。Opus 4.8 需要 v2.1.154 或更高版本。Sonnet 5 需要 v2.1.197 或更高版本
757* 如果您无法升级,请运行 `/model` 并选择 Opus 4.6 或 Sonnet 4.6 代替872* 如果您无法升级,请运行 `/model` 并选择 Opus 4.6 或 Sonnet 4.6 代替
758* {/* min-version: agent-sdk@0.3.197 */}如果您在 [Agent SDK](/zh-CN/agent-sdk/overview) 中遇到这个,请升级 SDK 包。Opus 4.8 需要 TypeScript SDK v0.3.154 或更高版本和 Python SDK v0.2.88 或更高版本。Sonnet 5 需要 TypeScript SDK v0.3.197 或更高版本873* {/* min-version: agent-sdk@0.3.197 */}}如果您在 [Agent SDK](/zh-CN/agent-sdk/overview) 中遇到这个,请升级 SDK 包。Opus 4.8 需要 TypeScript SDK v0.3.154 或更高版本和 Python SDK v0.2.88 或更高版本。Sonnet 5 需要 TypeScript SDK v0.3.197 或更高版本
759 874
760<h3 id="thinking-budget-exceeds-output-limit">875<h3 id="thinking-budget-exceeds-output-limit">
761 Thinking budget exceeds output limit876 Thinking budget exceeds output limit
790 905
791**要做什么:**906**要做什么:**
792 907
793* {/* max-version: 2.1.155 */}如果您使用的是 Opus 4.7 或 Opus 4.8,请先运行 `claude update`。v2.1.156 之前的版本可能在正常工具使用期间触发此错误,并且 `/rewind` 无法清除它。908* {/* max-version: 2.1.155 */}}如果您使用的是 Opus 4.7 或 Opus 4.8,请先运行 `claude update`。v2.1.156 之前的版本可能在正常工具使用期间触发此错误,并且 `/rewind` 无法清除它。
794* 运行 `/rewind`,或按 Esc 两次,回退到损坏轮次之前的检查点并从那里继续。有关如何创建和恢复检查点的信息,请参阅[检查点](/zh-CN/checkpointing)。909* 运行 `/rewind`,或按 Esc 两次,回退到损坏轮次之前的检查点并从那里继续。有关如何创建和恢复检查点的信息,请参阅[检查点](/zh-CN/checkpointing)。
795 910
796<h3 id="usage-policy-refusal">911<h3 id="usage-policy-refusal">
811* 如果您无法识别哪个轮次导致了它,请运行 `/clear` 以在同一项目中启动新的对话。您之前的对话已保存在磁盘上,并且在 `/resume` 中仍然可用。926* 如果您无法识别哪个轮次导致了它,请运行 `/clear` 以在同一项目中启动新的对话。您之前的对话已保存在磁盘上,并且在 `/resume` 中仍然可用。
812* 在[非交互模式](/zh-CN/headless)(`-p`)中,其中 rewind 不可用,使用重新表述的提示重试或启动新会话而不使用 `--continue`。927* 在[非交互模式](/zh-CN/headless)(`-p`)中,其中 rewind 不可用,使用重新表述的提示重试或启动新会话而不使用 `--continue`。
813 928
929<h2 id="command-line-errors">
930 命令行错误
931</h2>
932
933这些错误来自 Claude Code 自己对 `claude` 命令行的验证。Claude Code 立即打印它们,然后再创建会话或发送任何 API 请求。
934
935<h3 id="conflict-between-bg-and-print">
936 Conflict between --bg and --print
937</h3>
938
939{/* min-version: 2.1.198 */}}
940此消息需要 Claude Code v2.1.198 或更高版本。您在同一 `claude` 调用中组合了 `--bg` 与 `-p` 或 `--print`。`--bg` 启动[后台会话](/zh-CN/agent-view#from-your-shell),您稍后使用 `claude agents` 附加到,而 `--print` 运行[非交互式](/zh-CN/headless)并从不启动 `claude agents` 附加到的交互式会话。在 v2.1.198 之前,此组合默默创建了一个无法附加到的后台作业。
941
942```text theme={null}
943--bg and --print conflict: --print never starts the interactive session that `claude agents` attaches to, so the job would be unattachable. The prompt is the positional — drop --print: `claude --bg '<task>'`.
944```
945
946**要做什么:**
947
948* 删除 `-p` 或 `--print`。`--bg` 将提示作为其位置参数,因此 `claude --bg "<task>"` 是完整的命令。请参阅[从您的 shell 分派新代理](/zh-CN/agent-view#from-your-shell)。
949* 要非交互式运行提示并打印结果而不是创建后台会话,请删除 `--bg` 并运行 `claude -p "<task>"`
950
814<h2 id="responses-seem-lower-quality-than-usual">951<h2 id="responses-seem-lower-quality-than-usual">
815 响应质量似乎低于平常952 响应质量似乎低于平常
816</h2>953</h2>
838 报告错误975 报告错误
839</h2>976</h2>
840 977
841本页涵盖来自 Claude API 的错误。对于来自其他 Claude Code 组件的错误,请参阅相关指南:978对于本页不涵盖的组件的错误,请参阅相关指南:
842 979
843* MCP 服务器无法连接或身份验证:[MCP](/zh-CN/mcp)980* MCP 服务器无法连接或身份验证:[MCP](/zh-CN/mcp)
844* Hook 脚本失败或阻止了工具:[调试 hooks](/zh-CN/hooks#debug-hooks)981* Hook 脚本失败或阻止了工具:[调试 hooks](/zh-CN/hooks#debug-hooks)