[BUG] Unable to log into Claude Code on Windows
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude CLI version: 1.0.67 (Claude Code)
- Operating System: Windows 11
- Terminal: PowerShell
Bug Description
I'm unable to log into Claude Code from PowerShell. This is true whether I try from within a normal PowerShell instance or from inside my IDE (VS Code).
Steps to Reproduce
- Install Claude Code, either through npm or using the native binary.
- Open a new terminal.
- Start
claude. - Select a preferred theme and press Enter.
- Select a login method and press Enter.
Expected Behavior
I would expect to either be prompted for my credentials in the terminal or to be sent to the browser to complete the login flow.
Actual Behavior
The application errors out with the following message:
OAuth error: Port 45454 is already in use. Please ensure no other applications are
using this port.
Press Enter to retry.
Important to note: Port 45454 is _not_ already in use, as you'll see below.
Additional Context
I've tried the following:
- Running
netstat -aon | findstr :45454. Its output is empty. - Running
netsh int ipv4 show dynamicport tcpto ensure that 45454 is not in my dynamic port range. It isn't:
Protocol tcp Dynamic Port Range
---------------------------------
Start Port : 49152
Number of Ports : 16384
- As administrator, running
Get-Process -Id (Get-NetTCPConnection -LocalPort 45454).OwningProcess. This errors out withNo MSFT_NetTCPConnection objects found with property 'LocalPort' equal to '45454', as nothing's using that port. - Restarting my computer, just in case. It didn't help.
- Using
claude migrate-installerto migrateclaudefrom a global npm install to a local one, then restarting PowerShell. The port error persisted. - Removing the above, installing
claudeas a native binary directly, then restarting PowerShell. The port error persisted.
I'm currently managing to use Claude Code via an API key, which appears to have landed in settings.json somehow. (I both set it in PowerShell via ANTHROPIC_API_KEY and passed a batch script to apiKeyHelper in .claude.json -- not sure which one actually did the trick, as the former didn't work initially and the latter regularly throws an "Error getting API key" message in Claude Code.) I'd much rather be using my Pro account, though, for obvious reasons. Is there some way to pass Pro account credentials to Claude Code without having to use the tool's broken login flow?
This issue has 12 comments on GitHub. Read the full discussion on GitHub ↗