Skip to content

[BUG] OAuth error: The socket connection was closed unexpectedly. For more information, pass verbose: true in the second argument to fetch() #49761

Description

@atmclarke

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Claude Code fails on networks with broken QUIC/UDP path — no TCP fallback.

Claude Code fails to connect to api.anthropic.com (and other backend services) on networks where UDP port 443 / QUIC traffic is dropped or broken, even though TCP HTTPS to the same endpoints works fine. The underlying Bun runtime appears to prefer QUIC/HTTP/3 and does not fall back to TCP HTTPS when QUIC fails, unlike curl and mainstream browsers which implement fallback behaviour.

What Should Happen?

It should login.

Error Messages/Logs

OAuth error: The socket connection was closed unexpectedly. For more information, pass `verbose: true` in the second argument to fetch()

Steps to Reproduce

  1. Reproducible on specific networks where QUIC/UDP 443 is mangled in ways TCP HTTPS is not. I don't have a clean way to reproduce this on arbitrary hardware, and I suspect it'll be inconsistent across installs depending on firmware, MTU, and CGNAT state.
  2. Install Claude Code (any recent version)
  3. rm ~/.claude/.credentials.json to clear existing auth
  4. tcpdump 'host api.anthropic.com'
  5. run claude from terminal
  6. /login — browser completes, terminal errors with OAuth error: The socket connection was closed unexpectedly
  7. tcdump during Claude Code failure shows only QUIC (UDP 443) traffic — zero TCP SYN packets attempted
  8. curl https://api.anthropic.com succeeds (TCP HTTPS)
  9. Add rule: echo "block out proto udp from any to 160.79.104.0/24 port 443" | sudo tee /etc/pf.anchors/blockquic
  10. sudo pfctl -a blockquic -f /etc/pf.anchors/blockquic
  11. sudo pfctl -e
  12. run claude from terminal
  13. /login now works.

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

2.1.112

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions