Error Code Reference
Reference for QCode.cc API error codes: 400/401/402/403/429/500/502/503/529 semantics, typical causes and proven fixes, including INSUFFICIENT_BALANCE
On This Page
- Error Code Quick Reference
- 429 - Too Many Requests
- 502 - Bad Gateway
- 401 - Unauthorized
- 402 - Payment Required
- 403 - Forbidden
- 400 - Bad Request
- 500 - Internal Server Error
- 503 - Service Unavailable
- 529 - Overloaded
- Connection Timeout
- MCP Server Errors
- General Troubleshooting Steps
- Error Handling Best Practices
- Getting Help
This document provides detailed information about various error codes you may encounter while using Claude Code and their solutions.
Error Code Quick Reference¶
| Code | Type | Description | Severity |
|---|---|---|---|
| 400 | Client Error | Malformed request | Low |
| 401 | Auth Error | Invalid API Key | Medium |
| 402 | Channel Error | Upstream channel temporarily refusing | Medium |
| 403 | Permission Error | Access denied | Medium |
| 429 | Rate Limit | Too many requests | Medium |
| 500 | Server Error | Internal error | High |
| 502 | Gateway Error | Upstream unavailable | High |
| 503 | Service Unavailable | Temporarily overloaded | High |
| 529 | API Overloaded | Claude API overloaded | High |
429 - Too Many Requests¶
One of the most common errors, indicating too many requests in a short period.
Error Message¶
Error: 429 Too Many Requests
Rate limit exceeded. Please slow down your requests.
Common Causes¶
-
Too frequent requests: Sending multiple requests in rapid succession
-
Too many concurrent requests: Running multiple Claude Code instances simultaneously
-
Token limit reached: Consuming too many tokens in a short time
-
Quota exhausted: Daily/monthly quota depleted
Solutions¶
Immediate Actions:
# Wait 30-60 seconds before retrying
sleep 60 && claude "your question"
Long-term Solutions:
-
Reduce request frequency, avoid rapid consecutive sends
-
Use
/compactcommand to compress context -
Split large tasks into smaller batches
-
Consider upgrading to a higher quota plan
QCode.cc Advantage: Professional load balancing with multi-account pools to distribute request pressure, effectively reducing 429 errors.
502 - Bad Gateway¶
Indicates the gateway or proxy server received an invalid response from upstream.
Error Message¶
Error: 502 Bad Gateway
The server received an invalid response from the upstream server.
Common Causes¶
-
Upstream temporarily unavailable: Anthropic API server issues
-
Network connection interrupted: Connection dropped during request
-
Proxy server issues: Intermediate node failure
-
Request timeout: Response time exceeded gateway limit
Solutions¶
Immediate Actions:
# Check network connection
curl -s -o /dev/null -w '%{http_code}\n' \
-H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" https://api.qcode.cc/api/v1/models
# Wait and retry
sleep 30 && claude "your question"
Long-term Solutions:
-
Check local network stability
-
Try switching network environments
-
Use VPN or more stable network
-
Contact support if persistent
QCode.cc Advantage: Multi-region deployment, CDN acceleration, automatic failover, ensuring 99.9% availability.
401 - Unauthorized¶
Invalid API Key or missing valid authentication.
Error Message¶
Error: 401 Unauthorized
Invalid API key or authentication token.
Common Causes¶
-
Incorrect API Key: Missing characters or extra spaces when copying
-
Expired API Key: Subscription has expired
-
Disabled API Key: Banned due to policy violation
-
Environment variable not set:
ANTHROPIC_AUTH_TOKENnot configured
Solutions¶
Verify API Key:
# Check environment variable
echo $ANTHROPIC_AUTH_TOKEN
# Confirm correct format (starts with cr_)
# Correct example: cr_xxxxxxxxxxxxxxxxxxxx
Steps:
-
Login to QCode.cc Dashboard to check API Key status
-
Confirm subscription is active
-
If banned, contact support (QCode.cc provides immediate replacement service)
402 - Payment Required¶
The upstream channel refused this request. This is usually not a problem with your key or your configuration — requests from the same key to other models at the same time normally succeed.
What you see¶
Error: 402 Payment Required
In Claude Code it usually looks like the request simply failing with no response content; from a script or SDK you get HTTP 402.
Common causes¶
-
The upstream channel is temporarily unavailable: the QCode gateway never generates a 402 itself — it relays the status returned by the upstream
-
Concentrated on one model: at any given moment one model may see a high 402 rate while the others are completely fine
-
Depends on the endpoint domain: different domains route through different upstream paths, and the chance of hitting a 402 can differ substantially
-
Not related to your balance: running out of account balance or plan quota does not return 402 — that case says "daily cost limit reached", see the FAQ
What to do¶
1. Switch model (most effective)
# Switch inside a session
/model sonnet
# Or specify at launch
claude --model claude-sonnet-5
2. Switch endpoint domain
# Mainland China
export ANTHROPIC_BASE_URL=https://asia.qcode.cc/api
# Global (Route 53 picks the nearest node)
export ANTHROPIC_BASE_URL=https://api.qcode.cc/api
All four domains take the same key, so switching needs no other configuration change. See Endpoints & API Formats.
3. Don't write a tight retry loop
A 402 does not go away by resending immediately; hammering only makes it worse. Use exponential backoff, or just switch model — see "Error handling best practices" on this page.
4. If it persists, contact support
Include the time it happened, the model id and the endpoint domain, and reach us through live chat or hi@qcode.cc.
INSUFFICIENT_BALANCE / Insufficient account balance¶
Some 402/403 responses carry JSON like "code":"INSUFFICIENT_BALANCE", "message":"Insufficient account balance". This does not mean your QCode balance ran out. It is a temporary condition on one upstream channel passed through verbatim — unrelated to your account. When your own quota is used up, the message you actually see is "Daily cost limit reached" (see FAQ).
What to do: wait and retry / switch model / switch access domain (steps ①–③ above all apply); if it persists, contact support with the request id. Full checklist: troubleshooting guide.
403 - Forbidden¶
Request rejected by server, usually due to insufficient permissions.
Error Message¶
Error: 403 Forbidden
You don't have permission to access this resource.
Common Causes¶
-
Wrong API endpoint: Using incorrect API address
-
Insufficient permissions: Current plan doesn't support this feature
-
Regional restrictions: Some features unavailable in certain regions
-
Account status issues: Account restricted
Solutions¶
# Confirm API endpoint is correct
echo $ANTHROPIC_BASE_URL
# Should be: https://api.qcode.cc/api
-
Verify API endpoint configuration
-
Confirm plan includes required features
-
Contact support to verify permissions
INSUFFICIENT_BALANCE (when it appears on a 403)¶
If a 403 Forbidden body contains INSUFFICIENT_BALANCE / Insufficient account balance, this is again usually a temporary upstream-channel condition relayed verbatim — not your account being restricted. Handle it as in the same-named subsection of the 402 section; see the troubleshooting guide for the full order.
400 - Bad Request¶
Incorrect request format or invalid parameters.
Error Message¶
Error: 400 Bad Request
The request was malformed or contained invalid parameters.
Common Causes¶
-
Malformed request: Incorrect JSON format
-
Missing parameters: Required parameters not provided
-
Invalid values: Parameter values out of allowed range
-
Encoding issues: Special characters not properly encoded
Solutions¶
# Check for special characters in input
# Ensure request content is properly formatted
claude -p "simple test"
-
Simplify input, exclude special characters
-
Ensure file paths use correct encoding
-
Check command parameter format
500 - Internal Server Error¶
Server encountered unexpected condition preventing request completion.
Error Message¶
Error: 500 Internal Server Error
An unexpected error occurred on the server.
Common Causes¶
-
Server-side bug: API server code issue
-
Resource exhaustion: Server resources temporarily depleted
-
Configuration error: Server misconfiguration
Solutions¶
# Wait and retry
sleep 60 && claude "your question"
# Use verbose mode for more info
claude --verbose
-
Wait a few minutes and retry
-
Check QCode.cc service status
-
Contact support with error details if persistent
E015 - Conversation Context Overflow¶
Triggered when the conversation context approaches the model's capacity limit (~95%). QCode.cc wraps this error as a 429 response to trigger a retry:
429 {"error":{"code":"E015","message":"Internal server error"},"status":500}
Solution: See the "Long Session Overflow Prevention" section in Context Management.
503 - Service Unavailable¶
Server temporarily unable to handle requests, usually due to overload or maintenance.
Error Message¶
Error: 503 Service Unavailable
The service is temporarily unavailable. Please try again later.
Common Causes¶
-
Server overload: Request volume exceeds capacity
-
Scheduled maintenance: Server under maintenance
-
Resource exhaustion: Server resources temporarily insufficient
Solutions¶
# Use exponential backoff retry
for i in 1 2 4 8 16; do
claude "your question" && break
echo "Retrying, waiting ${i} seconds..."
sleep $i
done
-
Wait a few minutes and retry
-
Use exponential backoff retry strategy
-
Check service status announcements
529 - Overloaded¶
Claude API-specific error code indicating API service overload.
Error Message¶
Error: 529 Overloaded
The API is temporarily overloaded. Please try again later.
Common Causes¶
-
Global usage surge: Claude service global user spike
-
Peak hours: Concentrated requests during work hours
-
Popular events: Certain events causing usage surge
Solutions¶
# Retry later
sleep 120 && claude "your question"
-
Wait 2-5 minutes and retry
-
Avoid peak hours (US business hours)
-
Use
/compactto reduce token usage
QCode.cc Advantage: Multi-account pool rotation mechanism effectively distributes overload pressure.
Connection Timeout¶
Request failed to complete within the specified time.
Error Message¶
Error: Connection timed out
The request timed out while waiting for a response.
Common Causes¶
-
Unstable network: Poor network connection quality
-
Request too large: Too many context tokens
-
Task too complex: AI processing time too long
-
Slow server response: High server load
Solutions¶
# Test network connection
ping api.qcode.cc
# Use compact mode to reduce context
/compact
-
Check network connection stability
-
Use
/compactto compress context -
Split complex tasks into simpler ones
-
Try more stable network environment
MCP Server Errors¶
Errors that can come from MCP server configuration or runtime.
Symptoms¶
MCP server "xxx" failed to start
MCP connection timed out
MCP tool execution failed
Common Causes¶
-
Wrong server command: npx package name typo or not installed
-
Missing environment variables: the token the MCP server needs is not set
-
Timeout: server start-up or execution takes too long
-
Insufficient permissions: file system / database access denied
Solutions¶
# Check server status with /mcp
/mcp
# Diagnose configuration issues with /doctor
/doctor
# Manually test whether the MCP server can start
npx -y @modelcontextprotocol/server-filesystem /tmp
-
Check connection status with
/mcp -
Run automatic diagnostics with
/doctor -
Verify the format of
~/.claude/settings.jsonor.mcp.json -
Make sure required environment variables are set (
$GITHUB_TOKENetc.) -
Increase timeouts with the
MCP_TIMEOUTandMCP_TOOL_TIMEOUTenvironment variables
General Troubleshooting Steps¶
When encountering any error, follow these steps:
0. Run automatic diagnostics¶
# Claude Code's built-in diagnostic tool
/doctor
This automatically checks common configuration issues: environment variables, API connectivity, MCP server status and more.
1. Check Network Connection¶
# Test API endpoint connectivity
curl -s -o /dev/null -w '%{http_code}\n' \
-H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" https://api.qcode.cc/api/v1/models
# Test DNS resolution
nslookup api.qcode.cc
2. Verify Environment Variables¶
# Check all relevant environment variables
echo "BASE_URL: $ANTHROPIC_BASE_URL"
echo "AUTH_TOKEN: ${ANTHROPIC_AUTH_TOKEN:0:10}..."
3. Enable Detailed Logging¶
# Use verbose mode for detailed info
claude --verbose
# Or set debug mode
DEBUG=true claude
4. Test Simple Request¶
# Send simple test request
claude -p "say hello"
5. Check Service Status¶
Visit QCode.cc for service status announcements.
Error Handling Best Practices¶
Implement Retry Mechanism¶
# Simple retry script
retry_claude() {
local max_attempts=3
local attempt=1
while [ $attempt -le $max_attempts ]; do
claude "$@" && return 0
echo "Attempt $attempt failed, retrying..."
sleep $((attempt * 2))
((attempt++))
done
echo "All attempts failed"
return 1
}
Monitor Usage¶
Regularly check API usage to avoid exceeding quota:
-
Login to QCode.cc Dashboard
-
View usage statistics
-
Set usage alerts
Optimize Requests¶
-
Reduce context: Regularly use
/compactor/clear -
Batch processing: Split large tasks into smaller ones
-
Avoid duplication: Cache common results
Getting Help¶
If the above solutions don't resolve your issue, contact QCode.cc support:
-
Live Chat: Bottom right corner of website
-
Response Time: 1-2 hours during business hours
-
Support Hours: 7×14 (9:00 AM - 11:00 PM daily)
When contacting support, please provide:
-
Complete error message
-
Command executed
-
Time of occurrence
-
API Key prefix (never share full key)