claude-code - 💡(How to fix) Fix Claude Code cannot establish TCP connections to local network hosts — No route to host (while iTerm2 succeeds) [1 participants]

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…
GitHub stats
anthropics/claude-code#47040Fetched 2026-04-13 05:43:04
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
labeled ×6

Root Cause

Claude Code is increasingly used for infrastructure management — SSH tunneling, firewall configuration, network diagnostics, multi-machine orchestration. During this investigation, Claude Code was unable to identify the root cause despite extensive debugging.

Fix Action

Workaround

SSH to the Raspberry Pi via iTerm2 and paste commands from Claude Code manually.


Code Example

VSCode (PID 1234)
Code Helper (Plugin) (PID 1446)
    → claude native binary (PID 1599)
/bin/zsh (PID $$) ← commands executed here
RAW_BUFFERClick to expand / collapse

Bug Report

When running commands from Claude Code (VSCode extension), TCP connections to a local network host fail with "No route to host" (errno 65). The exact same commands succeed when run from iTerm2 on the same machine, same user, same network interface.

Environment

  • macOS (Apple Silicon, M1 Mac mini, 16GB)
  • VSCode with Claude Code extension v2.1.101
  • Target: Raspberry Pi on same LAN (192.168.10.17, port 54444)

Reproduction

  1. From iTerm2: ssh -p 54444 [email protected]succeeds
  2. From Claude Code Bash tool: ssh -p 54444 [email protected]"No route to host"
  3. From Claude Code Python: socket.connect(('192.168.10.17', 54444))errno 65
  4. From Claude Code: traceroute 192.168.10.17succeeds (reaches host in 0.6ms)
  5. From Claude Code: ping 192.168.10.17"No route to host"
  6. From Claude Code: nc -z -w 5 192.168.10.17 54444fails
  7. From iTerm2: nc -z -w 5 192.168.10.17 54444succeeds

Investigation performed by Claude Code itself

Claude Code attempted to diagnose this issue autonomously and checked all of the following — none explained the discrepancy:

  • ARP: Resolves correctly (MAC address e4:5f:1:58:f1:25 visible on en0)
  • Routing table: Correct entry for 192.168.10.17 via en0
  • macOS Application Firewall: Disabled (socketfilterfw --getglobalstate → State = 0)
  • pf firewall: No active rules (pfctl -sr returns empty)
  • Process entitlements: No sandbox or network restrictions on the Claude binary or Code Helper (Plugin)
  • Proxy settings: None configured (system or VSCode level)
  • Network interface: Same en0 (192.168.10.6/24), same subnet
  • User/permissions: Same user (immr), same groups
  • Tailscale Network Extension: Installed and active, but disabling it (tailscale down) did not resolve the issue
  • macOS update: Persists after OS update

Process tree

VSCode (PID 1234)
  → Code Helper (Plugin) (PID 1446)
    → claude native binary (PID 1599)
      → /bin/zsh (PID $$) ← commands executed here

Key observation

traceroute succeeds (L3 reachability confirmed) but all TCP/UDP connections fail. This suggests filtering at the transport layer that is specific to the process tree originating from VSCode/Claude Code.

Expected behavior

Claude Code's Bash tool should have the same network access as any other terminal emulator running on the same machine under the same user.

Workaround

SSH to the Raspberry Pi via iTerm2 and paste commands from Claude Code manually.


Feature Request: Networking knowledge for infrastructure tasks

Claude Code is increasingly used for infrastructure management — SSH tunneling, firewall configuration, network diagnostics, multi-machine orchestration. During this investigation, Claude Code was unable to identify the root cause despite extensive debugging.

Suggestion: Strengthen the model's practical networking knowledge, particularly:

  • TCP/IP layer-by-layer diagnostics (L2/L3/L4 isolation)
  • OS-specific networking stacks (macOS Network Extensions, pf, Windows Firewall/WFP, Linux iptables/nftables)
  • ARP, routing table analysis, DNS fundamentals
  • Practical interpretation of diagnostic tools (traceroute, ping, netstat, ss, tcpdump)

This would significantly improve Claude Code's usefulness for system administration tasks across diverse environments.

extent analysis

TL;DR

The issue can be worked around by using iTerm2 for SSH connections to the Raspberry Pi, as the problem seems specific to the process tree originating from VSCode/Claude Code.

Guidance

  • Investigate the differences in network configuration and process environment between VSCode/Claude Code and iTerm2 to identify the root cause of the "No route to host" error.
  • Verify that the issue persists when running commands directly from the claude native binary (PID 1599) to isolate if the problem is specific to the binary or the VSCode/Claude Code integration.
  • Check for any macOS-specific security features or sandboxing that might be applied to the VSCode or Claude Code process tree, restricting network access.
  • Consider using a tool like tcpdump or Wireshark to capture and compare network traffic from both iTerm2 and VSCode/Claude Code to identify any differences in packet formation or routing.

Example

No specific code example is provided due to the nature of the issue, which seems to be related to the environment and configuration rather than a code snippet.

Notes

The issue might be related to how macOS handles network connections from different applications, especially those running under specific extensions or plugins like Claude Code in VSCode. The fact that traceroute succeeds but TCP connections fail suggests a layer 4 (transport layer) issue that is specific to the process tree of VSCode/Claude Code.

Recommendation

Apply the workaround of using iTerm2 for SSH connections until the root cause can be identified and addressed, as it allows for continued functionality while the issue is being investigated.

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's Bash tool should have the same network access as any other terminal emulator running on the same machine under the same user.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING