From b69cebd5b3d9c7bbf4eba7764cbc7818ea060313 Mon Sep 17 00:00:00 2001 From: FAQ Bot Date: Fri, 4 Sep 2026 00:58:14 +0000 Subject: [PATCH 1/2] =?UTF-8?q?NEW:=20Claude=20Code=20login=20fails=20in?= =?UTF-8?q?=20GitHub=20Codespaces=20with=20=E2=80=9Clocalhost=20refused=20?= =?UTF-8?q?to?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...e-codespaces-localhost-refused-callback.md | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 _questions/ai-dev-tools-zoomcamp/misc/006_9a1eef9e91_claude-code-codespaces-localhost-refused-callback.md diff --git a/_questions/ai-dev-tools-zoomcamp/misc/006_9a1eef9e91_claude-code-codespaces-localhost-refused-callback.md b/_questions/ai-dev-tools-zoomcamp/misc/006_9a1eef9e91_claude-code-codespaces-localhost-refused-callback.md new file mode 100644 index 00000000..a32bf6f9 --- /dev/null +++ b/_questions/ai-dev-tools-zoomcamp/misc/006_9a1eef9e91_claude-code-codespaces-localhost-refused-callback.md @@ -0,0 +1,23 @@ +--- +id: 9a1eef9e91 +question: Claude Code login fails in GitHub Codespaces with “localhost refused to + connect” — how do I fix it? +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” docs for other known causes. \ No newline at end of file From aa5292f81878640f3f31518899f9ad738b1fc639 Mon Sep 17 00:00:00 2001 From: Alexey Grigorev Date: Wed, 9 Sep 2026 14:57:51 +0200 Subject: [PATCH 2/2] Fix Codespaces login FAQ: How-question, Anthropic docs link (#370) --- ...1_claude-code-codespaces-localhost-refused-callback.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/_questions/ai-dev-tools-zoomcamp/misc/006_9a1eef9e91_claude-code-codespaces-localhost-refused-callback.md b/_questions/ai-dev-tools-zoomcamp/misc/006_9a1eef9e91_claude-code-codespaces-localhost-refused-callback.md index a32bf6f9..e2842871 100644 --- a/_questions/ai-dev-tools-zoomcamp/misc/006_9a1eef9e91_claude-code-codespaces-localhost-refused-callback.md +++ b/_questions/ai-dev-tools-zoomcamp/misc/006_9a1eef9e91_claude-code-codespaces-localhost-refused-callback.md @@ -1,11 +1,11 @@ --- id: 9a1eef9e91 -question: Claude Code login fails in GitHub Codespaces with “localhost refused to - connect” — how do I fix it? +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. +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. @@ -20,4 +20,4 @@ curl "http://localhost:35251/oauth/callback?code=..." 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” docs for other known causes. \ No newline at end of file +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.