[API Error: Premature close]
What happened?
When I asked the gemini to do something, gemini give me the plan ,but failed to apply the code to the file
error in log file
"error": {
"message": "Premature close",
"stack": "Error: Premature close\n at IncomingMessage.<anonymous> (file:///Users/luang/.npm/_npx/38c708f8d73fe4c9/node_modules/@google/gemini-cli/bundle/gemini.js:50463:27)\n at Object.onceWrapper (node:events:632:28)\n at IncomingMessage.emit (node:events:518:28)\n at emitCloseNT (node:internal/streams/destroy:147:10)\n at process.processTicksAndRejections (node:internal/process/task_queues:81:21)"
}
│ │
│ Agent powering down. Goodbye! │
│ │
│ Performance │
│ Wall Time: 11m 54s │
│ Agent Active: 4m 9s │
│ » API Time: 4m 9s (100.0%) │
│ » Tool Time: 0s (0.0%) │
│ │
│ │
│ Model Usage Reqs Input Tokens Output Tokens │
│ ─────────────────────────────────────────────────────────────── │
│ gemini-2.5-pro 2 0 0 │
My operating system is: darwin
What did you expect to happen?
code should apply to file
Client information
╭──────────────────────────────────────────────────────────╮
│ │
│ About Gemini CLI │
│ │
│ CLI Version 0.1.12 │
│ Model gemini-2.5-pro │
│ Sandbox no sandbox │
│ OS darwin │
│ Auth Method OAuth │
│ GCP Project linen-flux-465807-j8 │
│ │
╰──────────────────────────────────────────────────────────╯
Login information
Google Account with cloud project id
Anything else we need to know?
No response
https://github.com/google-gemini/gemini-cli/blob/7c3a84075d03c84687339904c6421728fe520a6c/packages/core/src/tools/shell.ts#L418
Why write this here? ~~It will trigger this question.~~
Same problem, CLI wireless loop is calling, but it all says "[API Error: Premature close]", after waiting for more than 20 minutes, I press ESC, and then it crashes and exits.
Same issue,.Is it a bug? Or caused by chinese firewall?
china gcd 特色
fuck GFW
Try to update Gemini CLI?
npm install -g @google/gemini-cli@latest
My Gemini was back online after updating
Oh boy, this pesky error just can't resist making a comeback the second you let the version sit idle for a month or two.
Naturally, the tried-and-true path to salvation appears to be none other than npm install -g @google/gemini-cli@latest.
2025-11-11, infinitely repeating [API Error: Premature close], is Gemini still usable? The user experience is getting worse and worse.
Same issue
Since getting access to 3.0 in the CLI, every single request is getting the same issue identified here. I also seems to keep being told i'm on older versions even though I am now and I have removed gemini-cli from my system and re-added it.
Node 24.12.0 Windows 11 Pro Version: 25H2
│ About Gemini CLI
│
│ CLI Version 0.22.0
│ Git Commit f9331b160
│ Model auto-gemini-3
│ Sandbox no sandbox
│ OS win32
│ Auth Method OAuth
gemini --yolo is the command used to invoke Gemini. I have not been able to get a siccesfull response after 7 tries. Giving up.
您好,您发给我的信件已经收到~祝您生活愉快!--------------------------------------------厚德致远,博学敦行This is an automatic reply, confirming that your e-mail was received.Thank you
Same issue, still going on.
您好,您发给我的信件已经收到~祝您生活愉快!--------------------------------------------厚德致远,博学敦行This is an automatic reply, confirming that your e-mail was received.Thank you
same here.
I experienced a "Premature close" error when attempting to write multiple files consecutively using the write_file tool. Specifically, after successfully writing an initial file (index.html), subsequent calls to write_file (for style.css, script.js) consistently failed with this error.
It's been months and I am still getting this. Google blames this in client side connection which is complete BS. This has got to be fixed. I can't believe I am paying for this!
您好,您发给我的信件已经收到~祝您生活愉快!--------------------------------------------厚德致远,博学敦行This is an automatic reply, confirming that your e-mail was received.Thank you
换个节点试试?
@jmluang, this issue has been inactive for over a month. Could you please try reproducing it with the latest nightly build and let us know if it still occurs? If we don't hear back, we will close this issue on 2026-04-23.