[BUG] Unable to log into Claude Code on Windows

Status Fixed / completed
Maintainer reply ✓ Yes — ant-kurt
Activity 12 comments · opened Aug 2, 2025 · closed Aug 25, 2025
💡 Likely answer: A maintainer (ant-kurt, collaborator) responded on this thread — see the highlighted reply below.

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

  1. Install Claude Code, either through npm or using the native binary.
  2. Open a new terminal.
  3. Start claude.
  4. Select a preferred theme and press Enter.
  5. 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 tcp to 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 with No 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-installer to migrate claude from a global npm install to a local one, then restarting PowerShell. The port error persisted.
  • Removing the above, installing claude as 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?

View original on GitHub ↗

12 Comments

joeybenamy · 1 year ago

I have the same problem.

trueegorletov · 1 year ago

Have the same issue

DxTa · 1 year ago

I got the same issue as well, so can help test new fix if needed

ine8181 · 1 year ago

Seems to work when I run as an administrator.

github-actions[bot] · 1 year ago

Found 2 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/3402
  2. https://github.com/anthropics/claude-code/issues/1841

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

scoussens · 1 year ago
Found 2 possible duplicate issues: 1. [[BUG] claude-code for Windows is NOT available due to its port #3402](https://github.com/anthropics/claude-code/issues/3402) 2. [[BUG] OAuth error: listen EACCES: permission denied 0.0.0.0:54545 #1841](https://github.com/anthropics/claude-code/issues/1841) 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

This issue still exists in the latest version of the build for windows (1.0.72) and this particular issue references the port number for this version.

scoussens · 1 year ago

I got an email with the following comment, and I tried this and it worked.

_@vanhemsj left a comment
anthropics/claude-code#5008
Run these commands in PowerShell as Administrator:
wsl --shutdown
net stop hns
net start hns
Note: The net stop hns command might show an error or hang, but continue with net start hns anyway - it should still fix the issue. ( i dont know why it worked for me )_

I didn't have to stop WSL, only run the net stop and start commands as an admin and then the claude authentication worked.

Guthman · 1 year ago

Same error. Running netstat -a -b doesn't show any other processing using the port. In WSL (where I also have Claude Code installed, but not running) executing netstat -pln also doesn't show any processes using this port.

However running net stop hns and then net start hns worked.

ant-kurt collaborator · 1 year ago

Can you try netsh int ip show excludedportrange protocol=tcp?

Guthman · 1 year ago

C:\Users\xxx>netsh int ip show excludedportrange protocol=tcp

Protocol tcp Port Exclusion Ranges

Start Port End Port
---------- --------
5357 5357
5985 5985
47001 47001
49711 49810
49811 49910
50000 50059 *
50131 50131
50132 50231
50260 50359
50460 50559
55437 55536
55537 55636
55646 55745
55746 55845
59444 59543

  • - Administered port exclusions.
ant-kurt collaborator · 1 year ago

This should be working better in the upcoming release!

github-actions[bot] · 12 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.