Course
ai-dev-tools-zoomcamp
Question
I'm using Claude Code in GitHub Codespaces for isolation, but login fails with "localhost refused to connect." How do I fix it?
Answer
Claude Code's OAuth login opens a browser tab pointing at http://localhost:PORT/callback. In Codespaces this can fail to load, because the browser reaches that URL through Codespaces' port-forwarding proxy instead of talking to the listener directly.
Workaround:
- Run
claude and let it open the login link in your browser.
- When the page fails to load, copy the full URL from the address bar (e.g.
http://localhost:35251/oauth/callback?code=...).
- Open a second terminal tab in the Codespace and run:
curl "http://localhost:35251/oauth/callback?code=..."
- Your original terminal logs in immediately.
This works because the curl runs inside the Codespace, on the same machine as the listener, so it bypasses the forwarding proxy entirely.
If this doesn't resolve your login error, check Anthropic's Troubleshoot installation and login page for other known causes.
Checklist
Course
ai-dev-tools-zoomcamp
Question
I'm using Claude Code in GitHub Codespaces for isolation, but login fails with "localhost refused to connect." How do I fix it?
Answer
Claude Code's OAuth login opens a browser tab pointing at
http://localhost:PORT/callback. In Codespaces this can fail to load, because the browser reaches that URL through Codespaces' port-forwarding proxy instead of talking to the listener directly.Workaround:
claudeand let it open the login link in your browser.http://localhost:35251/oauth/callback?code=...).curl "http://localhost:35251/oauth/callback?code=..."This works because the
curlruns inside the Codespace, on the same machine as the listener, so it bypasses the forwarding proxy entirely.If this doesn't resolve your login error, check Anthropic's Troubleshoot installation and login page for other known causes.
Checklist