[BUG] OAuth login fails with "Failed to start OAuth callback server: Failed to start server. Is port 0 in use?

Status Fixed / completed
Reported on v2.1.50
Maintainer reply None cached
Activity 4 comments · opened Feb 21, 2026 · closed Feb 21, 2026

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?

Hello,

Steps to reproduce:

  1. Run claude
  2. Execute /login
  3. Error appears immediately
❯ test 
  ⎿  API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"OAuth token has expired. Please obtain a new token or refresh your existing
     token."},"request_id":"req_011CYMDHeNYmSgx9MxiJhzrf"} · Please run /login

❯ /login  

 OAuth error: Failed to start OAuth callback server: Failed to start server. Is port 0 in use?

Environment:

  • Claude Code version: [run claude --version]

❯ claude --version
2.1.50 (Claude Code)

  • OS: [e.g., macOS 14.2, Ubuntu 22.04, Windows 11]

❯ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm

  • Shell: [e.g., bash, zsh, PowerShell]

Bash

  • Installation method: [native/npm/homebrew]

Native

Additional context:

  • Previous login attempt was interrupted
  • Token expired with 401 authentication error
  • No other Claude Code instances running

Expected behavior:
OAuth flow should open browser for authentication.

What Should Happen?

Claude should allow me to login without issue

Error Messages/Logs

Steps to Reproduce

Can't know

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.50

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Xterm

Additional Information

_No response_

View original on GitHub ↗

4 Comments

github-actions[bot] · 7 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/11469
  2. https://github.com/anthropics/claude-code/issues/16521
  3. https://github.com/anthropics/claude-code/issues/9376

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

s-celles · 7 months ago

Symptoms looks similar but I'm not using macOS.

s-celles · 7 months ago

Closing as it was a permission issue on /etc/hosts (not 644)

github-actions[bot] · 7 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.