gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

Gemini CLI crashes when play.googleapis.com is not reachable

Open acheng314159 opened this issue 1 year ago • 20 comments

What happened?

Every time I type gemini to launch the Gemini CLI, it automatically exits after a short while and returns to PS C:\Users\30671>. I don’t know the reason, but now I can’t perform any operations—it just closes immediately.

What did you expect to happen?

Tips for getting started:

  1. Ask questions, edit files, or run commands.
  2. Be specific for the best results.
  3. Create GEMINI.md files to customize your interactions with Gemini.
  4. /help for more information.

╭──────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ > / │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ▲ auth change the auth method bug submit a bug report chat Manage conversation history. Usage: /chat <list|save|resume> [tag] clear clear the screen and conversation history compress Compresses the context by replacing it with a summary. docs open full Gemini CLI documentation in your browser editor set external editor preference help for help on gemini-cli ▼ (7/15)

~ no sandbox (see /docs) gemini-2.5-pro (100% context left)

PS C:\Users\30671>

Client information

$ gemini /about
# paste output here

Login information

No response

Anything else we need to know?

No response

acheng314159 avatar Jun 26 '25 02:06 acheng314159

me too. same problem.

jualopezo avatar Jun 26 '25 02:06 jualopezo

me too.

hiyizi avatar Jun 26 '25 03:06 hiyizi

me, three

sccsbc avatar Jun 26 '25 03:06 sccsbc

me four

jax-max avatar Jun 26 '25 03:06 jax-max

Can affected folks please note the platform & version you are using? e.g. everything in /about, or if that's not available, use gemini -v and tell us your OS.

markmcd avatar Jun 26 '25 03:06 markmcd

About Gemini CLI │ │ │ │ CLI Version 0.1.4 │ │ Git Commit 1078a54 │ │ Model gemini-2.5-pro │ │ Sandbox no sandbox │ │ OS darwin

@markmcd

jax-max avatar Jun 26 '25 04:06 jax-max

Image It might be due to the IP address, I wonder if it can be changed to a domain name?

hiyizi avatar Jun 26 '25 04:06 hiyizi

Thanks for the posts so far! Running in debug mode can help too - gemini -d - see if you get any specific errors there.

markmcd avatar Jun 26 '25 04:06 markmcd

Thanks for the posts so far! Running in debug mode can help too - gemini -d - see if you get any specific errors there.

"RITICAL: Unhandled Promise Rejection!

Reason: AggregateError [ETIMEDOUT]: at internalConnectMultiple (node:net:1139:18) at afterConnectMultiple (node:net:1712:7) { code: 'ETIMEDOUT', [errors]: [ Error: connect ETIMEDOUT 2001:4860:4802:34::223:443 at createConnectionError (node:net:1675:14) at Timeout.internalConnectMultipleTimeout (node:net:1734:38) at listOnTimeout (node:internal/timers:596:11) at process.processTimers (node:internal/timers:529:7) { errno: -60, code: 'ETIMEDOUT', syscall: 'connect', address: '2001:4860:4802:34::223', port: 443 }, Error: connect ETIMEDOUT 216.239.36.223:443 at createConnectionError (node:net:1675:14) at Timeout.internalConnectMultipleTimeout (node:net:1734:38) at listOnTimeout (node:internal/timers:596:11) at process.processTimers (node:internal/timers:529:7) { errno: -60, code: 'ETIMEDOUT', syscall: 'connect', address: '216.239.36.223', port: 443 }," I encountered the same problem. When using gemini -d, there was a timeout for this IP.

bingxueai123456 avatar Jun 26 '25 05:06 bingxueai123456

使用wsl2运行的时候, 需要先安装windows docker desktop 然后在wsl中 设置export GEMINI_SANDBOX=docker 这个环境变量 GEMINI_SANDBOX=docker geminicli才能正常 识别到docker 解决没有沙盒的问题

然后在大陆使用代理,使用tun模式,确保能连接到 auth.docker.io 不然初始化会失败,导致退出

如果还是不行,尝试从源码开始运行,会看到更多信息

huadaox avatar Jun 26 '25 05:06 huadaox

same crash reason:

Code Assist login required.
Attempting to open authentication page in your browser.
Otherwise navigate to:

https://accounts.google.com/o/oauth2/v2/auth?redirect_uri=http%3A%2F%2Flocalhost%3A59948%2Foauth2callback&access_type=offline&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile&state=e61a1a97af275947d0f2be251f9c11fb5b34936aaff2cd8c2a59b2c57db8bff3&response_type=code&client_id=681255809395-oo8ft2oprdrnp9e3aqf6av3hmdib135j.apps.googleusercontent.com


Waiting for authentication...
Authenticated via "oauth-personal".
Clearcut POST request error:  AggregateError [ETIMEDOUT]: 
    at internalConnectMultiple (node:net:1139:18)
    at afterConnectMultiple (node:net:1712:7) {
  code: 'ETIMEDOUT',
  [errors]: [
    Error: connect ETIMEDOUT 216.239.36.223:443
        at createConnectionError (node:net:1675:14)
        at Timeout.internalConnectMultipleTimeout (node:net:1734:38)
        at listOnTimeout (node:internal/timers:596:11)
        at process.processTimers (node:internal/timers:529:7) {
      errno: -60,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '216.239.36.223',
      port: 443
    },
    Error: connect ETIMEDOUT 216.239.34.223:443
        at createConnectionError (node:net:1675:14)
        at Timeout.internalConnectMultipleTimeout (node:net:1734:38)
        at listOnTimeout (node:internal/timers:596:11)
        at process.processTimers (node:internal/timers:529:7) {
      errno: -60,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '216.239.34.223',
      port: 443
    },
    Error: connect ETIMEDOUT 216.239.38.223:443
        at createConnectionError (node:net:1675:14)
        at Timeout.internalConnectMultipleTimeout (node:net:1734:38)
        at listOnTimeout (node:internal/timers:596:11)
        at process.processTimers (node:internal/timers:529:7) {
      errno: -60,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '216.239.38.223',
      port: 443
    },
    Error: connect ETIMEDOUT 216.239.32.223:443
        at createConnectionError (node:net:1675:14)
        at afterConnectMultiple (node:net:1705:16) {
      errno: -60,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '216.239.32.223',
      port: 443
    }
  ]
}
=========================================
CRITICAL: Unhandled Promise Rejection!
=========================================
Reason: AggregateError [ETIMEDOUT]: 
    at internalConnectMultiple (node:net:1139:18)
    at afterConnectMultiple (node:net:1712:7) {
  code: 'ETIMEDOUT',
  [errors]: [
    Error: connect ETIMEDOUT 216.239.36.223:443
        at createConnectionError (node:net:1675:14)
        at Timeout.internalConnectMultipleTimeout (node:net:1734:38)
        at listOnTimeout (node:internal/timers:596:11)
        at process.processTimers (node:internal/timers:529:7) {
      errno: -60,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '216.239.36.223',
      port: 443
    },
    Error: connect ETIMEDOUT 216.239.34.223:443
        at createConnectionError (node:net:1675:14)
        at Timeout.internalConnectMultipleTimeout (node:net:1734:38)
        at listOnTimeout (node:internal/timers:596:11)
        at process.processTimers (node:internal/timers:529:7) {
      errno: -60,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '216.239.34.223',
      port: 443
    },
    Error: connect ETIMEDOUT 216.239.38.223:443
        at createConnectionError (node:net:1675:14)
        at Timeout.internalConnectMultipleTimeout (node:net:1734:38)
        at listOnTimeout (node:internal/timers:596:11)
        at process.processTimers (node:internal/timers:529:7) {
      errno: -60,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '216.239.38.223',
      port: 443
    },
    Error: connect ETIMEDOUT 216.239.32.223:443
        at createConnectionError (node:net:1675:14)
        at afterConnectMultiple (node:net:1705:16) {
      errno: -60,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '216.239.32.223',
      port: 443
    }
  ]
}
Stack trace may follow:

tsaijamey avatar Jun 26 '25 05:06 tsaijamey

This looks like an error while authenticating. Have you already been through the auth process successfuly? (e.g. signed in with gmail)

By successfully I mean, you clicked the login thing in your browser and came back to the Gemini CLI and made API calls?

And do you have any network filters that might be blocking this IP? PiHoles, intercepting VPNs, firewalls etc.

markmcd avatar Jun 26 '25 06:06 markmcd

This looks like an error while authenticating. Have you already been through the auth process successfuly? (e.g. signed in with gmail)

By successfully I mean, you clicked the login thing in your browser and came back to the Gemini CLI and made API calls?

And do you have any network filters that might be blocking this IP? PiHoles, intercepting VPNs, firewalls etc.“ I have logged in already, the gemini - cli exited during my usage , and the firewall has been turned off, and the VPN should not restrict this IP.

bingxueai123456 avatar Jun 26 '25 06:06 bingxueai123456

After enabling TUN mode in the VPN, it worked—though I'm not entirely sure why

acheng314159 avatar Jun 26 '25 06:06 acheng314159

Same problem. Gemini cli crashed after a few second launched, even when using api-key login success.

Authenticated via "gemini-api-key".
Clearcut POST request error:  AggregateError [ETIMEDOUT]:
    at internalConnectMultiple (node:net:1134:18)
    at afterConnectMultiple (node:net:1715:7) {
  code: 'ETIMEDOUT',
  [errors]: [
    Error: connect ETIMEDOUT 216.239.34.223:443
        at createConnectionError (node:net:1678:14)
        at Timeout.internalConnectMultipleTimeout (node:net:1737:38)
        at listOnTimeout (node:internal/timers:590:11)
        at process.processTimers (node:internal/timers:523:7) {
      errno: -4039,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '216.239.34.223',
      port: 443
    },
    Error: connect ETIMEDOUT 216.239.32.223:443
        at createConnectionError (node:net:1678:14)
        at Timeout.internalConnectMultipleTimeout (node:net:1737:38)
        at listOnTimeout (node:internal/timers:590:11)
        at process.processTimers (node:internal/timers:523:7) {
      errno: -4039,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '216.239.32.223',
      port: 443
    },
    Error: connect ETIMEDOUT 216.239.38.223:443
        at createConnectionError (node:net:1678:14)
        at Timeout.internalConnectMultipleTimeout (node:net:1737:38)
        at listOnTimeout (node:internal/timers:590:11)
        at process.processTimers (node:internal/timers:523:7) {
      errno: -4039,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '216.239.38.223',
      port: 443
    },
    Error: connect ETIMEDOUT 216.239.36.223:443
        at createConnectionError (node:net:1678:14)
        at afterConnectMultiple (node:net:1708:16) {
      errno: -4039,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '216.239.36.223',
      port: 443
    }
  ]
}
=========================================                                                                                                               
CRITICAL: Unhandled Promise Rejection!                                                                                                                  
=========================================                                                                                                               
Reason: AggregateError [ETIMEDOUT]:                                                                                                                     
    at internalConnectMultiple (node:net:1134:18)                                                                                                       
    at afterConnectMultiple (node:net:1715:7) {                                                                                                         
  code: 'ETIMEDOUT',                                                                                                                                    
  [errors]: [                                                                                                                                           
    Error: connect ETIMEDOUT 216.239.34.223:443                                                                                                         
        at createConnectionError (node:net:1678:14)                                                                                                     
        at Timeout.internalConnectMultipleTimeout (node:net:1737:38)                                                                                    
        at listOnTimeout (node:internal/timers:590:11)
        at process.processTimers (node:internal/timers:523:7) {
      errno: -4039,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '216.239.34.223',
      port: 443
    },
    Error: connect ETIMEDOUT 216.239.32.223:443
        at createConnectionError (node:net:1678:14)
        at Timeout.internalConnectMultipleTimeout (node:net:1737:38)
        at listOnTimeout (node:internal/timers:590:11)
        at process.processTimers (node:internal/timers:523:7) {
      errno: -4039,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '216.239.32.223',
      port: 443
    },
    Error: connect ETIMEDOUT 216.239.38.223:443
        at createConnectionError (node:net:1678:14)
        at Timeout.internalConnectMultipleTimeout (node:net:1737:38)
        at listOnTimeout (node:internal/timers:590:11)
        at process.processTimers (node:internal/timers:523:7) {
      errno: -4039,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '216.239.38.223',
      port: 443
    },
    Error: connect ETIMEDOUT 216.239.36.223:443
        at createConnectionError (node:net:1678:14)
        at afterConnectMultiple (node:net:1708:16) {
      errno: -4039,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '216.239.36.223',
      port: 443
    }
  ]
}
Stack trace may follow:

LinLinLinzp avatar Jun 26 '25 07:06 LinLinLinzp

Same problem. Gemini cli crashed after a few second launched, even when using api-key login success.

Authenticated via "gemini-api-key".
Clearcut POST request error:  AggregateError [ETIMEDOUT]:
    at internalConnectMultiple (node:net:1134:18)
    at afterConnectMultiple (node:net:1715:7) {
  code: 'ETIMEDOUT',
  [errors]: [
    Error: connect ETIMEDOUT 216.239.34.223:443
        at createConnectionError (node:net:1678:14)
        at Timeout.internalConnectMultipleTimeout (node:net:1737:38)
        at listOnTimeout (node:internal/timers:590:11)
        at process.processTimers (node:internal/timers:523:7) {
      errno: -4039,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '216.239.34.223',
      port: 443
    },
    Error: connect ETIMEDOUT 216.239.32.223:443
        at createConnectionError (node:net:1678:14)
        at Timeout.internalConnectMultipleTimeout (node:net:1737:38)
        at listOnTimeout (node:internal/timers:590:11)
        at process.processTimers (node:internal/timers:523:7) {
      errno: -4039,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '216.239.32.223',
      port: 443
    },
    Error: connect ETIMEDOUT 216.239.38.223:443
        at createConnectionError (node:net:1678:14)
        at Timeout.internalConnectMultipleTimeout (node:net:1737:38)
        at listOnTimeout (node:internal/timers:590:11)
        at process.processTimers (node:internal/timers:523:7) {
      errno: -4039,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '216.239.38.223',
      port: 443
    },
    Error: connect ETIMEDOUT 216.239.36.223:443
        at createConnectionError (node:net:1678:14)
        at afterConnectMultiple (node:net:1708:16) {
      errno: -4039,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '216.239.36.223',
      port: 443
    }
  ]
}
=========================================                                                                                                               
CRITICAL: Unhandled Promise Rejection!                                                                                                                  
=========================================                                                                                                               
Reason: AggregateError [ETIMEDOUT]:                                                                                                                     
    at internalConnectMultiple (node:net:1134:18)                                                                                                       
    at afterConnectMultiple (node:net:1715:7) {                                                                                                         
  code: 'ETIMEDOUT',                                                                                                                                    
  [errors]: [                                                                                                                                           
    Error: connect ETIMEDOUT 216.239.34.223:443                                                                                                         
        at createConnectionError (node:net:1678:14)                                                                                                     
        at Timeout.internalConnectMultipleTimeout (node:net:1737:38)                                                                                    
        at listOnTimeout (node:internal/timers:590:11)
        at process.processTimers (node:internal/timers:523:7) {
      errno: -4039,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '216.239.34.223',
      port: 443
    },
    Error: connect ETIMEDOUT 216.239.32.223:443
        at createConnectionError (node:net:1678:14)
        at Timeout.internalConnectMultipleTimeout (node:net:1737:38)
        at listOnTimeout (node:internal/timers:590:11)
        at process.processTimers (node:internal/timers:523:7) {
      errno: -4039,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '216.239.32.223',
      port: 443
    },
    Error: connect ETIMEDOUT 216.239.38.223:443
        at createConnectionError (node:net:1678:14)
        at Timeout.internalConnectMultipleTimeout (node:net:1737:38)
        at listOnTimeout (node:internal/timers:590:11)
        at process.processTimers (node:internal/timers:523:7) {
      errno: -4039,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '216.239.38.223',
      port: 443
    },
    Error: connect ETIMEDOUT 216.239.36.223:443
        at createConnectionError (node:net:1678:14)
        at afterConnectMultiple (node:net:1708:16) {
      errno: -4039,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '216.239.36.223',
      port: 443
    }
  ]
}
Stack trace may follow:

试试把代理改成tun模式,可以解决这个问题。

bingxueai123456 avatar Jun 26 '25 07:06 bingxueai123456

The IP is for play.googleapis.com. If that's not accessible it will cause the error. The "workaround" is to fix that.

Otherwise I'll leave this open to track a fix where it doesn't fail the whole app if this network issue fails.

markmcd avatar Jun 26 '25 07:06 markmcd

The problem is that the clearcut-logger is not using proxy even if http_proxy/https_proxy env variables are defined. Here's a patch to fix this issue:

diff --git a/packages/core/src/telemetry/clearcut-logger/clearcut-logger.ts b/packages/core/src/telemetry/clearcut-logger/clearcut-logger.ts
index 7afe7ecc..b3476fc9 100644
--- a/packages/core/src/telemetry/clearcut-logger/clearcut-logger.ts
+++ b/packages/core/src/telemetry/clearcut-logger/clearcut-logger.ts
@@ -6,6 +6,7 @@
 
 import { Buffer } from 'buffer';
 import * as https from 'https';
+import { HttpsProxyAgent } from 'https-proxy-agent';
 import {
   StartSessionEvent,
   EndSessionEvent,
@@ -98,12 +99,17 @@ export class ClearcutLogger {
         },
       ];
       const body = JSON.stringify(request);
-      const options = {
+      const options: https.RequestOptions = {
         hostname: 'play.googleapis.com',
         path: '/log',
         method: 'POST',
         headers: { 'Content-Length': Buffer.byteLength(body) },
       };
+
+      if (this.config?.getProxy()) {
+        options.agent = new HttpsProxyAgent(this.config.getProxy() as string);
+      }
+
       const bufs: Buffer[] = [];
       const req = https.request(options, (res) => {
         res.on('data', (buf) => bufs.push(buf));

gouzhuang avatar Jun 26 '25 08:06 gouzhuang

We've improved resilience against network issues over the last week a lot; should be fixed now. Please let me know if that's not true.

sethtroisi avatar Jul 01 '25 21:07 sethtroisi

Closing as it has been 27 days and there have been no comments that the issue persists.

jacob314 avatar Jul 28 '25 19:07 jacob314