Debug note — WiFi latency · Claude Code & Codex

⚠ Issue

Claude Code and Codex CLI were consistently slow on home WiFi, but fast when tethered to a mobile hotspot. Browser-based AI and video streaming were unaffected on the same WiFi.


🔬 Diagnosis

Two curl tests measured round-trip time to api.anthropic.com over each network protocol.

IPv6 connection slow
0.173 s
Default path — what CLI tools use
IPv4 connection fast
0.078 s
2.2× faster; what hotspot uses

The verbose curl output confirmed the OS defaulted to IPv6 (address 2607:6bc0::10). No proxy interception detected. TLS certificate was legitimate (Google Trust Services / Anthropic on Google Cloud).

Root cause: The WiFi router advertises IPv6, so the OS prefers it. The ISP's IPv6 routing path to Anthropic's servers is poorly optimized — 95ms slower per connection. Hotspot uses a different carrier with no IPv6, or a better IPv6 path.

Browser AI is unaffected because browsers silently retry IPv4 on slow IPv6. CLI tools do not.


📚 Glossary

ISP Internet Service Provider — the company you pay for internet. All traffic travels through their hardware before reaching the wider internet.
IPv4 The original internet addressing scheme. Addresses look like 192.168.1.1. 40 years of infrastructure = fast, well-optimized routes everywhere.
IPv6 The newer, larger address scheme. Addresses look like 2607:6bc0::10. Routes are less mature — ISPs vary wildly in IPv6 quality.
TCP conn. A "phone call" between your machine and a server. Must be opened before any data flows. Each API call opens one.
SSE Server-Sent Events — how AI APIs stream tokens back one by one over a single open connection. You feel every millisecond of latency in real time.
Happy Eyeballs The OS algorithm that picks IPv6 over IPv4 when both are available. Browsers implement fallback to IPv4; CLI tools often don't.

🔌 How a CLI session works

Single API call — token streaming
your terminal ISP network Anthropic API tokens stream word · by · word HTTPS IPv6 ⚠ SSE
A coding task — sequential calls, latency multiplies
read files analyze generate tool call refine +95ms +95ms +95ms +95ms ≈ 380ms wasted per task each gap = IPv6 overhead · calls are sequential — can't skip any
Why video is unaffected
Video stream 30s buffered ahead — latency invisible CLI token stream wait · token · wait · token · wait... you feel every gap

🔧 Fix

Disable IPv6 on the WiFi interface. On macOS: System Settings → Network → WiFi → Details → TCP/IP → Configure IPv6 → Off. Or via terminal: sudo networksetup -setv6off Wi-Fi. This forces all CLI traffic onto the faster IPv4 path without affecting anything else.