Claude Code Bash hits a timeout or moves to the background. Raise the limits
Foreground Bash defaults to 2 minutes (max 10). Long builds move to the background or stop if backgrounding is off. Raise BASH_* timeouts or background the job. Short answer: 5 steps. 1) Read the timeout message before you restart Claude; 2) Raise the foreground default and ceiling with env vars; 3) Prefer intentional background runs for servers and watch builds; 4) If commands die at the timeout, check CLAUDE_CODE_DISABLE_BACKGROUND_TASKS; 5) Verify after the change.
Last updated: · This page is the decision checklist; the tools list for “Fix Claude Code Bash timeouts” is a separate URL.
How do I raise Bash timeouts or background the job when Claude Code hits a timeout?
Read the timeout message before you restart Claude
If a foreground command exceeds its timeout, Claude Code normally moves it to the background and reports something like “Command did not complete within its 120s timeout and was moved to the background,” with a task ID and an output file path. That is expected—not a crash. Open `/tasks` (or ask Claude to check the background task) instead of killing the session. Tools reference: https://code.claude.com/docs/en/tools-reference
Raise the foreground default and ceiling with env vars
You do not set a per-command timeout yourself; Claude may pass a `timeout` on the tool call. Control the defaults with `BASH_DEFAULT_TIMEOUT_MS` (2 minutes out of the box) and `BASH_MAX_TIMEOUT_MS` (10-minute ceiling by default; the effective ceiling is the larger of the two). Put them under `env` in `~/.claude/settings.json` or project settings, for example `{"env":{"BASH_DEFAULT_TIMEOUT_MS":"300000","BASH_MAX_TIMEOUT_MS":"600000"}}` for a 5-minute default and 10-minute max. Env vars: https://code.claude.com/docs/en/env-vars
Prefer intentional background runs for servers and watch builds
For long-running processes (dev servers, watchers, long installs), ask Claude to start them with `run_in_background: true` so work continues while they run. List or stop them with `/tasks`. In unattended sessions (`-p`, Agent SDK, CI, cloud), background Bash/PowerShell commands have their own time limits (often 30 minutes default, up to 2 hours)—raise those with the same `BASH_*` variables when you need longer. Docs: https://code.claude.com/docs/en/tools-reference
If commands die at the timeout, check CLAUDE_CODE_DISABLE_BACKGROUND_TASKS
Setting `CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1` (or bare mode) disables auto-backgrounding, so a command that hits its timeout stops instead of moving to the background. Turn that off when you want long foreground work to continue in the background, or raise the timeout so the command finishes first.
Verify after the change
Start a fresh Claude Code session so settings/`env` reload. Re-run a known long command (or ask Claude to print the effective timeout plan). Confirm `/tasks` shows background work when expected, and that directory changes inside a backgrounded command do not change the session cwd—the docs warn those `cd` effects do not carry over.
Which tools are best to fix Claude Code Bash timeouts?
Claude Code tools reference
Bash timeout defaults, auto-backgrounding, and background time limits.
Environment variables
BASH_DEFAULT_TIMEOUT_MS, BASH_MAX_TIMEOUT_MS, and CLAUDE_CODE_DISABLE_BACKGROUND_TASKS.
Settings
Where to put env overrides in user or project settings.json.
Interactive mode / tasks
How /tasks lists and stops background commands.
Open: 1 spot per week
One labeled sponsor for this topic each week; this week's spot is open. See open weeks →
All tools for “Fix Claude Code Bash timeouts” →
Related fixes
- Stop a Cursor agent loopHow to fix a Cursor agent loop (same edit, or work after Stop)Fix →
- Claude Code vs Codex vs Cursor ~$20 plansClaude Code vs Codex vs Cursor $20 plan limits: how to pick without burning the weekFix →
- Scan a vibe-coded app for leaked API keysCheck a vibe-coded app for leaked API keys before you share itFix →
- Add an MCP server to Claude Code, Cursor, or CodexHow to add an MCP server to Claude Code, Cursor, or CodexFix →
See also AI tools launched today on the daily board.
NewAIToolsToday Daily
Top 3 AI launches, one model or news item that matters, and one simple fix. A 5-minute read, every weekday.