gemini-cli - 💡(How to fix) Fix [Bug] Authentication fails with 'Client network socket disconnected' under TUN proxy [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
google-gemini/gemini-cli#25255Fetched 2026-04-14 05:56:27
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Timeline (top)
labeled ×3commented ×1

Error Message

When using `gemini auth login` on a Linux system (Ubuntu) with a system-level TUN mode proxy (e.g., Clash Verge), the authentication process fails at the final verification step. The browser OAuth redirect succeeds and the token is saved, but the CLI throws a socket disconnection error during the API check. Error Message:

Root Cause

Root Cause Analysis:

  1. IPv6 Leak: Node.js prefers IPv6, which often bypasses TUN interfaces on Linux, leading to a direct connection that is blocked/reset by the firewall (GFW).
  2. TLS Rejection: Node.js strict TLS verification rejects the proxied connection when using local interception.

Fix Action

Fix / Workaround

Workaround: Using `env NODE_TLS_REJECT_UNAUTHORIZED=0` and forcing an IPv4 application-level proxy resolves the issue. Disabling IPv6 at the kernel level also helps.

RAW_BUFFERClick to expand / collapse

Description: When using `gemini auth login` on a Linux system (Ubuntu) with a system-level TUN mode proxy (e.g., Clash Verge), the authentication process fails at the final verification step. The browser OAuth redirect succeeds and the token is saved, but the CLI throws a socket disconnection error during the API check.

Error Message: ```text Failed to sign in. Message: request to https://cloudcode-pa.googleapis.com/v1internal:loadCodeAssist failed, reason: Client network socket disconnected before secure TLS connection was established ```

Root Cause Analysis:

  1. IPv6 Leak: Node.js prefers IPv6, which often bypasses TUN interfaces on Linux, leading to a direct connection that is blocked/reset by the firewall (GFW).
  2. TLS Rejection: Node.js strict TLS verification rejects the proxied connection when using local interception.

Workaround: Using `env NODE_TLS_REJECT_UNAUTHORIZED=0` and forcing an IPv4 application-level proxy resolves the issue. Disabling IPv6 at the kernel level also helps.

Environment:

  • OS: Ubuntu (Linux)
  • Proxy: Clash Verge (TUN mode)

extent analysis

TL;DR

Setting NODE_TLS_REJECT_UNAUTHORIZED=0 and using an IPv4 proxy or disabling IPv6 at the kernel level may resolve the authentication issue with gemini auth login on Linux systems with a TUN mode proxy.

Guidance

  • Verify that the issue is indeed caused by an IPv6 leak or TLS rejection by checking the system's IPv6 configuration and the proxy settings.
  • Try setting NODE_TLS_REJECT_UNAUTHORIZED=0 before running gemini auth login to disable strict TLS verification.
  • Use an IPv4 application-level proxy to force the connection to go through the proxy, instead of relying on the system's IPv6 configuration.
  • Consider disabling IPv6 at the kernel level as a more permanent solution, but be aware of potential implications for other system services.

Example

env NODE_TLS_REJECT_UNAUTHORIZED=0 gemini auth login

This command sets the environment variable to disable strict TLS verification for the duration of the command.

Notes

The provided workaround may have security implications, as it disables strict TLS verification. It is essential to understand the potential risks and consider alternative solutions that do not compromise security.

Recommendation

Apply the workaround by setting NODE_TLS_REJECT_UNAUTHORIZED=0 and using an IPv4 proxy, as it is a relatively simple and effective solution to the issue. However, it is crucial to weigh the security trade-offs and consider more permanent solutions that address the root cause of the problem.

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