[BUG] Resumed sessions fail after VPN connect (DNS caching in Bun)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Resumed sessions fail after VPN connect (DNS caching in Bun)
Summary
When connecting to a VPN after a Claude Code session has started, the session fails with "Connection error" and "unknown certificate verification error". Fresh sessions started after VPN is connected work fine.
Environment
- Claude Code version: 2.0.75
- OS: macOS Darwin 24.6.0
- Shell: zsh
- VPN: Corporate VPN (Cisco AnyConnect)
Steps to Reproduce
- Start Claude Code session (no VPN)
- Connect to VPN
- Try to continue conversation or resume session
- Session fails with connection errors
Expected Behavior
Session should continue working after VPN connects, or gracefully reconnect.
Actual Behavior
Session fails with errors like:
Error streaming, falling back to non-streaming mode: Connection error.
Failed to fetch version from https://storage.googleapis.com/...: unknown certificate verification error
Debug log shows ~25 consecutive "Connection error" failures.
Root Cause Analysis
Through debugging, I confirmed:
- VPN is not intercepting SSL (verified with
openssl s_client- real Google Trust Services certs) curlandopensslwork fine on VPNNODE_TLS_REJECT_UNAUTHORIZED=0andNODE_EXTRA_CA_CERTSare set but don't help- Fresh sessions started after VPN connects work perfectly
This points to DNS caching in Bun. When the session starts, Bun resolves and caches DNS for api.anthropic.com and storage.googleapis.com. When VPN connects, DNS routing changes (different DNS server, potentially different resolved IPs), but Bun continues using the cached (now unreachable) IPs.
Workaround
Always start a fresh session after connecting to VPN. Don't resume sessions that were started before VPN.
Suggested Fix
- Bun/Claude Code should detect network changes and invalidate DNS cache
- Or retry with fresh DNS resolution on connection failures
- Or expose a command to manually refresh connections
Debug Log
I have this if needed
What Should Happen?
Resuming sessions on or off VPN should work.
Error Messages/Logs
58 +2025-12-21T15:13:34.567Z [DEBUG] Failed to check metrics opt-out status: unknown certificate verification error
59 +2025-12-21T15:13:34.576Z [DEBUG] Failed to fetch Grove notice config: Error: unknown certificate verification error
60 +2025-12-21T15:13:34.740Z [ERROR] Error streaming, falling back to non-streaming mode: Connection error.
61 +2025-12-21T15:13:34.744Z [ERROR] Error streaming, falling back to non-streaming mode: Connection error.
62 +2025-12-21T15:13:34.746Z [ERROR] Error streaming, falling back to non-streaming mode: Connection error.
63 +2025-12-21T15:13:35.437Z [ERROR] Error: Error: Failed to fetch version from https://storage.googleapis.com/claude-code-dist-86c565f3-f756
+-42ad-8dfa-d59b1c096819/claude-code-releases/latest: unknown certificate verification error
64 +2025-12-21T15:13:35.437Z [ERROR] Error: Error: Failed to fetch version from latest: Error: unknown certificate verification error
65 +2025-12-21T15:13:35.569Z [ERROR] Error: Error: Connection error.
66 +2025-12-21T15:13:35.574Z [ERROR] Error: Error: Connection error.
67 +2025-12-21T15:13:35.576Z [ERROR] Error: Error: Connection error.
68 +2025-12-21T15:13:35.583Z [ERROR] Error: Error: Connection error.
69 +2025-12-21T15:13:35.584Z [ERROR] Error: Error: Connection error.
70 +# ... 20+ more Connection error lines over the next ~100ms ...
71 +
72 +
73 +Full debug log available on request.
Steps to Reproduce
- Disconnect from VPN (ensure normal internet connection)
- Start Claude Code:
claude - Have a brief conversation to confirm it's working
- Connect to corporate VPN (Cisco AnyConnect in my case)
- Send another message in the same session
- Observe: connection errors, session becomes unresponsive
Alternative repro (resume):
- Start Claude Code session without VPN, have conversation
- Exit Claude Code
- Connect to VPN
- Resume session:
claude --resume - Observe: same connection errors
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.0.75
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗