Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
id: 9a1eef9e91
question: How do I fix Claude Code login failing with "localhost refused to connect"
in GitHub Codespaces?
sort_order: 6
---

Claude Code's OAuth login opens a browser tab pointing at `http://localhost:PORT/callback`. In GitHub Codespaces, that callback URL can fail to load because the browser reaches it through Codespaces' port-forwarding proxy instead of talking directly to the listener.

Workaround:
1. Run `claude` and let it open the login link in your browser.
2. When the page fails to load, copy the full callback URL from the address bar (for example `http://localhost:35251/oauth/callback?code=...`).
3. In a second terminal tab inside the same Codespace, run:

```bash
curl "http://localhost:35251/oauth/callback?code=..."
```

4. Your original `claude` terminal should log in immediately.

Why this works: the `curl` runs inside the Codespace on the same machine as the listener, so it bypasses the forwarding proxy.

If this still doesn't resolve it, check Anthropic's [Troubleshoot installation and login](https://code.claude.com/docs/en/troubleshoot-install) docs for other known causes.
Loading