Allow configuring API connection max retry attempts
Resolved 💬 4 comments Opened Mar 9, 2026 by zhoubeiqing Closed Apr 14, 2026
Feature Request
Problem
When Claude Code fails to connect to the API (e.g., UND_ERR_SOCKET), it retries up to 10 times by default. This value is hardcoded and cannot be configured.
In some network environments (unstable connections, proxy setups, etc.), 10 retries means a long wait when the API is genuinely unreachable. Users should be able to control this behavior.
Current Behavior
Unable to connect to API (UND_ERR_SOCKET)
Retrying in 0 seconds… (attempt 10/10)
The max retry count (10) is hardcoded with no way to override it.
Proposed Solution
Add a configurable option for API connection max retry attempts. This could be:
- An environment variable, e.g.,
CLAUDE_API_MAX_RETRIES=4 - A setting in
~/.claude/settings.json, e.g.,"apiMaxRetries": 4 - A CLI flag, e.g.,
claude --max-retries 4
Any of these approaches would work. The key requirement is that users can reduce (or increase) the retry count based on their network conditions.
Use Case
- Users behind corporate proxies or firewalls who know quickly whether the connection will succeed
- Users who prefer fast failure over long retry loops
- CI/CD environments where fast failure is preferred
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗