claude-code - 💡(How to fix) Fix [BUG] GitHub MCP OAuth flow fails on claude.ai/code — localhost callback unreachable [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#45100Fetched 2026-04-09 08:13:16
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Author
Timeline (top)
labeled ×6commented ×1

Error Message

Error Messages/Logs

Code Example

ERR_CONNECTION_REFUSED on localhost
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

The mcp__github__authenticate tool generates an OAuth URL with redirect_uri=http://localhost:{port}/callback

This only works when Claude Code runs as a local CLI (which spins up a temporary HTTP server). On claude.ai/code (web) and mobile, the localhost callback is unreachable:

ERR_CONNECTION_REFUSED on localhost

Steps to reproduce:

  1. Use Claude Code on claude.ai/code (web interface)
  2. Call mcp__github__authenticate
  3. Open the generated OAuth URL
  4. Complete Google/GitHub authorization
  5. Callback redirects to localhost → connection refused

Expected: OAuth should work on all Claude Code platforms Suggested fix: Use a hosted callback endpoint (e.g., api.anthropic.com/callback) that can relay the auth token back to the session, or provide a manual token paste flow as fallback.

What Should Happen?

Expected: OAuth should work on all Claude Code platforms Suggested fix: Use a hosted callback endpoint (e.g., api.anthropic.com/callback) that can relay the auth token back to the session, or provide a manual token paste flow as fallback.

<img width="1166" height="684" alt="Image" src="https://github.com/user-attachments/assets/b916c50c-bb2b-40b4-bf3f-e58dee2f586b" /> <img width="947" height="668" alt="Image" src="https://github.com/user-attachments/assets/cf774d88-a759-4f44-9caa-9bff99049449" />

Error Messages/Logs

ERR_CONNECTION_REFUSED on localhost

Steps to Reproduce

Steps to reproduce:

  1. Use Claude Code on claude.ai/code (web interface)
  2. Call mcp__github__authenticate
  3. Open the generated OAuth URL
  4. Complete Google/GitHub authorization
  5. Callback redirects to localhost → connection refused

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

Claude Code 2.1.96

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Other

Additional Information

No response

extent analysis

TL;DR

The most likely fix is to use a hosted callback endpoint, such as api.anthropic.com/callback, to relay the auth token back to the session, or provide a manual token paste flow as a fallback.

Guidance

  • Identify a suitable hosted callback endpoint that can handle OAuth redirects for Claude Code on web and mobile platforms.
  • Update the mcp__github__authenticate tool to generate an OAuth URL with the new callback endpoint.
  • Consider implementing a manual token paste flow as a fallback for cases where the hosted callback endpoint is not accessible.
  • Verify that the new callback endpoint can correctly relay the auth token back to the session.

Example

No code snippet is provided as the issue does not contain sufficient technical details to generate a specific example.

Notes

The suggested fix relies on the availability of a hosted callback endpoint, such as api.anthropic.com/callback, which may require additional setup or configuration.

Recommendation

Apply a workaround by using a hosted callback endpoint, as it is a more reliable and scalable solution than relying on localhost callbacks.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING