Troubleshooting

Claude Code error troubleshooting

Find your error code, get one line on why it happens and one step to fix it. Almost every setup problem comes down to three things: the environment variable never took effect, the URL is wrong, or you hit the concurrency ceiling. Start with the table — most of these take thirty seconds.

Quick reference

What you seeUsually meansDo this first
401 · Invalid tokenKey not in effect or truncatedFull walkthrough →
403Key disabled or out of scopeFull walkthrough →
429 · rate limitConcurrency ceiling, not balanceFull walkthrough →
Connection errorWrong URL or blocked networkFull walkthrough →
SSL / certificateProxy intercepting TLSFull walkthrough →
model not foundWrong version or suffix in the idFull walkthrough →
context length exceededConversation grew too longFull walkthrough →
Streaming cuts off midwayProxy idle timeoutRaise the proxy read timeout
529 · overloadedUpstream model is saturatedRetry later or switch model
x-bb-api-key and other third-party errorsReturned by another service, not by 9CodingIdentify the source →

Connection and authentication

401 · Invalid token#

Symptom
The request is rejected outright, with a body like {"error":{"code":"","message":"Invalid token (request id: 2026...)","type":"new_api_error"}}.
Cause
The server did not recognise the key. Nine times out of ten the key itself is fine — either the environment variable never took effect or the value was truncated when copied.
Fix

First confirm the shell actually sees them:

terminal
echo $ANTHROPIC_BASE_URL
echo $ANTHROPIC_AUTH_TOKEN

Empty output means the variables never reached this shell, or you did not restart the terminal after adding them. Claude Code reads environment variables once at startup — open a new terminal (or source ~/.zshrc) after any change.

Output looks right but still 401? Check the key begins with sk-9c- and nothing is missing from the end. Recopying it from the console is the safest move.

403 · Forbidden#

Symptom
The key is recognised, but this particular call is not allowed.
Cause
The key has been disabled or deleted, or its scope is restricted.
Fix
Open the key management page in the console and confirm the key still exists and is active. Deleting it and creating a fresh one is the fastest way to rule this out — new keys work immediately, with no propagation delay.

Connection error#

Symptom
The request fails before reaching the server: connection error, ECONNREFUSED, or a timeout.
Cause
Either the URL is wrong or traffic cannot leave your machine. Take Claude Code out of the picture first — one curl separates the two cases.
Fix
terminal
curl -s https://api.9coding.com/v1/models \
  -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN"

curl works (returns a model list or a JSON error) → the network is fine and it is client configuration. Check ANTHROPIC_BASE_URL for typos, a trailing /, or an extra /v1. The correct value is exactly https://api.9coding.com — the client appends the path itself.

curl also fails → network or proxy. Check whether your proxy only applies to the browser, whether corporate policy blocks the host, and run curl -v to see which step stalls.

SSL / certificate errors#

Symptom
Certificate verification failures, unable to get local issuer certificate, or handshake timeouts.
Cause
Something in the middle — a proxy or security agent — is terminating TLS, and its root certificate is not trusted by your system.
Fix
Install that proxy's root certificate into the system trust store, or turn the proxy off briefly to confirm it is the cause. Do not work around this by disabling certificate verification — that hands your traffic to whoever is in the middle.

Rate limits and timeouts

429 · rate limit#

Symptom
Requests are throttled with a rate limit or too many requests message.
Cause
You hit the concurrency ceiling — this is not a balance problem. The two are worded differently; insufficient balance says so explicitly.
Fix

Wait a few seconds and retry; it normally clears itself. Hitting it repeatedly means too much runs in parallel — bring the number of concurrent tasks down.

Always give batch scripts exponential backoff: 1s, 2s, 4s, rather than retrying flat out. Aggressive retries only keep the limit engaged for longer.

529 · overloaded#

Symptom
A 529 response, or a message saying the model is overloaded.
Cause
The upstream model is under heavy load. Nothing to do with your configuration; popular models see this at peak hours.
Fix
Retry shortly, or switch to a comparable model to keep working. Use /model inside Claude Code — your session is preserved.
More
If it died mid-answer with no retry at all, that is the other arrival path and the standard retry mechanisms do not cover it — see 529 overloaded in depth.

Streaming responses cut off midway#

Symptom
Output stops partway through with no error, or the connection is reported as reset.
Cause
A streamed response is one long-lived connection, and an idle timeout anywhere along the path will cut it. Corporate proxies and some VPNs are the usual culprits.
Fix
Raise the proxy read timeout — long answers easily exceed 60 seconds — or bypass the proxy to confirm. A quick test: ask for a short answer. If short answers complete and long ones always break, it is a timeout.

Models and parameters

model not found#

Symptom
The model is reported as missing or unavailable.
Cause
A hand-typed id with the wrong version or an extra suffix. Model ids are case and hyphen sensitive — one character off and it will not resolve.
Fix

Ask the server what is currently available and copy the id verbatim:

terminal
curl -s https://api.9coding.com/v1/models \
  -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN"

Inside Claude Code, use /model and pick from the list — more reliable than typing it.

context length exceeded#

Symptom
An error saying the context limit or token count has been exceeded.
Cause
The conversation has outgrown the model context window. Most common in long sessions or after loading a large file in one go.
Fix

/clear for a fresh session, or /compact to condense the history and carry on.

The durable fix is not to load an entire repository up front — letting the tool read files on demand is both cheaper and more accurate.

None of the above? Work through this order

When you hit something unfamiliar, do not start by guessing. This order narrows it to one place within a few minutes:

  1. Check the environment: echo $ANTHROPIC_BASE_URL $ANTHROPIC_AUTH_TOKEN. Empty means it never took effect — restart the terminal.
  2. Bypass the client: run the curl above. Success means client configuration; failure means network.
  3. Try another model: one bad model and a broken channel need completely different fixes.
  4. Minimal repro: open an empty session and ask something trivial. Errors inside complex sessions are often about context, not access.
  5. Still stuck? Send it to us — with the details below.
Include these four things: ① the full error text, especially the request id inside it (request id: 2026... — it points straight at that one call); ② when it happened; ③ the model name; ④ the result of the curl in step 2. With those four it is usually a single-pass diagnosis; "it doesn't work" cannot be investigated.

Related