[BUG] Resumed sessions fail after VPN connect (DNS caching in Bun)

Resolved 💬 4 comments Opened Dec 21, 2025 by lynxbat Closed Dec 25, 2025

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

  1. Start Claude Code session (no VPN)
  2. Connect to VPN
  3. Try to continue conversation or resume session
  4. 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)
  • curl and openssl work fine on VPN
  • NODE_TLS_REJECT_UNAUTHORIZED=0 and NODE_EXTRA_CA_CERTS are 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

  1. Disconnect from VPN (ensure normal internet connection)
  2. Start Claude Code: claude
  3. Have a brief conversation to confirm it's working
  4. Connect to corporate VPN (Cisco AnyConnect in my case)
  5. Send another message in the same session
  6. Observe: connection errors, session becomes unresponsive

Alternative repro (resume):

  1. Start Claude Code session without VPN, have conversation
  2. Exit Claude Code
  3. Connect to VPN
  4. Resume session: claude --resume
  5. 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_

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗