claude-code - 💡(How to fix) Fix Session terminates with 'Sock-hopping' on long-running bash commands (~4+ min) in WSL2

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Claude Code terminates mid-session when a bash tool call takes approximately 4 or more minutes to complete. The session ends with a Sock-hopping… message and a resume ID. This is a regression — the same workflow ran without issue on earlier versions.

Error Message

After ~4 minutes of waiting for the bash command to complete, the session prints:

Root Cause

Claude Code terminates mid-session when a bash tool call takes approximately 4 or more minutes to complete. The session ends with a Sock-hopping… message and a resume ID. This is a regression — the same workflow ran without issue on earlier versions.

Fix Action

Fix / Workaround

  • The ctrl+b background option is not a viable workaround for unattended/automated workflows
  • Session checkpointing appears to work correctly (resume ID is printed)
  • This did not occur on earlier versions of Claude Code — it appears to be a regression introduced at or before 2.1.150
  • Hypothesis: the streaming connection to the Anthropic API is being dropped due to inactivity while the CLI waits for the subprocess to finish, and the reconnect ("sock-hopping") fails rather than recovering transparently

Code Example

* Sock-hopping… (4m 25s · ↓ 1.9k tokens)

---

Resume this session with:
claude --resume <session-id>
RAW_BUFFERClick to expand / collapse

Summary

Claude Code terminates mid-session when a bash tool call takes approximately 4 or more minutes to complete. The session ends with a Sock-hopping… message and a resume ID. This is a regression — the same workflow ran without issue on earlier versions.

Environment

  • Claude Code version: 2.1.150
  • Platform: WSL2 (Ubuntu, version 2) on Windows
  • Shell: bash
  • Model: Claude Sonnet 4.6

Steps to reproduce

  1. Start a Claude Code session inside WSL2
  2. Trigger (or instruct Claude to run) a bash command that takes 4+ minutes (e.g. a large test suite: python -m pytest)
  3. Wait without interacting with the UI

Observed behavior

After ~4 minutes of waiting for the bash command to complete, the session prints:

* Sock-hopping… (4m 25s · ↓ 1.9k tokens)

followed immediately by:

Resume this session with:
claude --resume <session-id>

and the process exits. The bash command output is never returned and the tool call never completes.

Expected behavior

Claude Code should hold the streaming connection open (or transparently reconnect) while a bash tool call is running, and complete the tool call regardless of duration. A 4-minute test run should not terminate the session.

Notes

  • The ctrl+b background option is not a viable workaround for unattended/automated workflows
  • Session checkpointing appears to work correctly (resume ID is printed)
  • This did not occur on earlier versions of Claude Code — it appears to be a regression introduced at or before 2.1.150
  • Hypothesis: the streaming connection to the Anthropic API is being dropped due to inactivity while the CLI waits for the subprocess to finish, and the reconnect ("sock-hopping") fails rather than recovering transparently

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Claude Code should hold the streaming connection open (or transparently reconnect) while a bash tool call is running, and complete the tool call regardless of duration. A 4-minute test run should not terminate the session.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Session terminates with 'Sock-hopping' on long-running bash commands (~4+ min) in WSL2