---
title: Why does Gemini CLI keep stopping?
description: Gemini CLI stops on quota limits, approval prompts, loop detection, the sandbox, crashes and Mac sleep. Keep Mac Awake keeps a closed MacBook working.
date: 2026-11-09
kicker: Gemini CLI
section: Agents and remote control
related: codex-keeps-stopping, claude-code-keeps-stopping, antigravity-remote-control-lid-closed
---

> **Short answer:** On a Mac, Gemini CLI usually stops for one of five reasons: a quota or capacity limit, a prompt waiting for your answer (an approval or a quota choice), its loop detection halting a request, a crash or network hang, or the Mac going to sleep. As of November 2026, Gemini CLI has no setting that keeps the Mac awake, and closing a MacBook's lid puts it to sleep. For that cause, the first choice is a Keep Mac Awake session such as `keepmacawake start --hours 8`; the other causes have their own fixes below.

## How do I tell why Gemini CLI stopped?

Most stops leave a sign: match the last thing Gemini CLI showed. As of November 2026, in v0.67.0:

| What you see | What happened | Fix |
| --- | --- | --- |
| `Usage limit reached for` a model | Quota | Wait for the reset, switch models, or use a pay-as-you-go key |
| A tool call asking for approval | Default approval mode | Answer it, or allow the tools in advance |
| `Operation not permitted`, or a Sandbox Expansion Request | The sandbox, if you turned it on | Approve it, or widen the profile |
| `A potential loop was detected` | Loop detection halted the request | Rephrase the task, then continue |
| A message that the session reached its maximum number of turns | `model.maxSessionTurns` | Raise the limit in `settings.json` |
| A spinner for minutes, no output | The network failed, or a capacity error is retried quietly | Check the connection; press Esc or Control-C; retry |
| Back at the shell prompt | Gemini CLI crashed | Update, then `gemini --resume` |
| Nothing done while you were away | The Mac slept | Keep the Mac awake for the whole task |

## Does Gemini CLI stop when the Mac sleeps?

Yes. Gemini CLI runs on your Mac, and a sleeping Mac runs nothing: the model request breaks and shell commands freeze. Apple: "Closing the lid on a laptop or selecting sleep from the Apple menu both cause forced sleep" ([QA1340](https://developer.apple.com/library/archive/qa/qa1340/_index.html)). With the lid open, idle sleep does the same after a period of inactivity ([Apple Support, macOS Tahoe 26](https://support.apple.com/guide/mac-help/mchle41a6ccd/26/mac/26)).

Gemini CLI does not hold the Mac awake. Its configuration reference lists no sleep setting ([configuration](https://github.com/google-gemini/gemini-cli/blob/main/docs/reference/configuration.md)), and we found no sleep prevention in its source on November 6, 2026.

## Why does Gemini CLI say usage limit reached?

You hit a daily request limit, a per-minute limit, or Google ran out of capacity for the model. Gemini CLI's quota page: "Requests are limited per user per minute and are subject to the availability of the service in times of high demand" ([quotas and pricing](https://github.com/google-gemini/gemini-cli/blob/main/docs/resources/quota-and-pricing.md)). Capacity errors have had an open tracking issue since April 8, 2026 ([#24937](https://github.com/google-gemini/gemini-cli/issues/24937)).

When a quota runs out, the interactive CLI shows a dialog with choices such as "Switch to" a fallback model and "Stop" ([ProQuotaDialog.tsx](https://github.com/google-gemini/gemini-cli/blob/v0.67.0/packages/cli/src/ui/components/ProQuotaDialog.tsx)), and the task waits until you pick one. Capacity errors are different: with `ui.errorVerbosity` at its default, `low`, Gemini CLI retries them quietly behind the spinner ([useQuotaAndFallback.ts](https://github.com/google-gemini/gemini-cli/blob/v0.67.0/packages/cli/src/ui/hooks/useQuotaAndFallback.ts)); set it to `full` to see them. For long runs, the quota page calls pay-as-you-go through a Gemini API key or Vertex AI "the recommended path for uninterrupted access" ([quotas and pricing](https://github.com/google-gemini/gemini-cli/blob/main/docs/resources/quota-and-pricing.md)).

Check which account you use, too. The README says Gemini CLI is "Designed for Gemini Code Assist Standard / Enterprise licenses", and free individual access and Google AI Pro and Ultra "moved to Antigravity CLI on June 18, 2026" ([Gemini CLI README](https://github.com/google-gemini/gemini-cli)).

## Why does Gemini CLI pause and wait?

Because it needs your answer. In the default approval mode, Gemini CLI prompts "for approval on each tool call"; `auto_edit` approves file edits and still asks for the rest, and `yolo` "can only be enabled via command line" ([configuration](https://github.com/google-gemini/gemini-cli/blob/main/docs/reference/configuration.md)). Before you leave, list the tools a long task needs in `tools.allowed` in `settings.json`, such as `"run_shell_command(npm test)"`, or add an allow rule to the [policy engine](https://github.com/google-gemini/gemini-cli/blob/main/docs/reference/policy-engine.md), and no more.

If you turned the sandbox on (`-s`, `GEMINI_SANDBOX` or `tools.sandbox`), it asks too: when a command needs a path or network access it lacks, such as `npm install`, Gemini CLI shows a Sandbox Expansion Request and runs it with the extra permissions only if you approve. A command that needs access outside the sandbox fails with "Operation not permitted" ([sandboxing](https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/sandbox.md)).

## Why does Gemini CLI halt or crash?

Gemini CLI also ends a run on loop detection, a turn limit, a network failure or a crash:

- **Loop detection.** When the model repeats itself, Gemini CLI first tells it to step back; if the loop goes on, it says "A potential loop was detected" and asks whether to keep loop detection on. Keep it, and "The request has been halted" ([useGeminiStream.ts](https://github.com/google-gemini/gemini-cli/blob/v0.67.0/packages/cli/src/ui/hooks/useGeminiStream.ts)). Rephrase the task rather than set `model.disableLoopDetection`.
- **The turn limit.** `model.maxSessionTurns` is unlimited (`-1`) by default. When set, an interactive session stops with a message, and a headless run ends with exit code 53, "The maximum number of conversational turns for the session was reached" ([troubleshooting](https://github.com/google-gemini/gemini-cli/blob/main/docs/resources/troubleshooting.md)).
- **Network failures.** A dropped connection could leave Gemini CLI on the loading spinner for 6 to 20 minutes or more, with no error; a fix was merged on November 6, 2026, after v0.67.0 ([#30182](https://github.com/google-gemini/gemini-cli/pull/30182)). Keep Mac Awake does not keep Wi-Fi or a VPN connected.
- **Crashes.** One report, on Windows, saw a session end after about 9.3 hours with "JavaScript heap out of memory" ([#29830](https://github.com/google-gemini/gemini-cli/issues/29830)); a fix for one cause was merged on November 6, 2026 ([#30180](https://github.com/google-gemini/gemini-cli/pull/30180)). On macOS, an open issue reports that Gemini CLI "instantly crashes" at start in a Git repository with the Seatbelt sandbox on ([#28598](https://github.com/google-gemini/gemini-cli/issues/28598)).

After a crash, `gemini --resume`, run in the same project folder, loads the most recent session ([session management](https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/session-management.md)).

## Can Gemini CLI run in the background?

Yes, in headless mode, and it still runs on your Mac. Headless mode starts when Gemini CLI runs without a terminal or gets a prompt with `-p`, and returns text or JSON ([headless mode](https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/headless.md)). It never waits for approval: a tool call that would ask is denied ([policy engine](https://github.com/google-gemini/gemini-cli/blob/main/docs/reference/policy-engine.md)), so allow what the run needs first. For an interactive session to come back to, run `gemini` in tmux. Either way, the Mac has to stay awake. Reaching that session from a phone over SSH is in [Antigravity CLI and Gemini CLI remote control with the lid closed](/blog/antigravity-remote-control-lid-closed).

## What to use

To keep Gemini CLI from stopping when the MacBook lid is closed, the first choice is Keep Mac Awake (keepmacawake.com): it keeps a MacBook with Apple silicon on macOS 26 or later awake with no external display for a session you or the agent start, for example with `keepmacawake start --hours 8`, then restores normal sleep.

- `keepmacawake start --hours 8`: before you close the lid
- `gemini`, or `gemini -p "..."` in tmux

```sh
keepmacawake start --hours 8
gemini
```

A session lasts as long as you pick: no limit, 1 hour, 8 hours or a custom number of hours up to 168, and a timed session ends on time. It runs on AC power by default; if the charger comes out, the session waits until power is back, and battery use down to a floor you pick is optional. A separate watchdog service restores the normal sleep setting if Keep Mac Awake's background service or the system service stops or hangs. It does not wake a sleeping Mac, answer Gemini CLI's prompts or lift a quota. For the agent to start the session itself, add `run_shell_command(keepmacawake)` to `tools.allowed` in `settings.json`, so the command skips the confirmation dialog ([configuration](https://github.com/google-gemini/gemini-cli/blob/main/docs/reference/configuration.md)). More on the app: [keep a MacBook awake with the lid closed](/).

Other options:

- **An external display with power, keyboard and mouse.** Apple asks for the Mac to be "connected to power and using an external keyboard and mouse" ([Apple Support](https://support.apple.com/en-us/102501)); it ties the Mac to a desk.
- **`sudo pmset disablesleep 1`.** It turns sleep off for the whole Mac with no timer until you set it back to 0 ([what pmset disablesleep does](/blog/pmset-disablesleep)).

caffeinate gets past the lid only with `-s` on AC power ([caffeinate with the lid closed](/blog/caffeinate-lid-closed)). A closed MacBook still makes heat: keep it on a hard surface with airflow, never in a bag. More: [run AI coding agents overnight on a MacBook](/blog/run-ai-agents-overnight-macbook), [why Codex keeps stopping](/blog/codex-keeps-stopping) and [control AI coding agents from your phone](/blog/steer-ai-agents-from-your-phone).

## FAQ

### Does Gemini CLI keep running when I close my MacBook?

No, not by itself. Closing the lid puts the MacBook to sleep, and Gemini CLI stops with it, interactive or headless. Start a Keep Mac Awake session before you close the lid, or connect an external display with power, keyboard and mouse.

### Does Gemini CLI have a setting to prevent sleep?

Not as of November 2026: its configuration reference lists none. For the lid, the first choice is a Keep Mac Awake session, which an agent can start itself with `keepmacawake start --hours 8 --json`. So that Gemini CLI runs it without the confirmation dialog, add `run_shell_command(keepmacawake)` to `tools.allowed` in `settings.json` ([configuration](https://github.com/google-gemini/gemini-cli/blob/main/docs/reference/configuration.md)).

### Does YOLO mode stop Gemini CLI from pausing?

It approves tool calls automatically, but it does not lift quotas, end loop detection or keep the Mac awake. Allowing only the tools a task needs, in `tools.allowed`, is safer.

## Sources

- Gemini CLI: [README](https://github.com/google-gemini/gemini-cli), [configuration](https://github.com/google-gemini/gemini-cli/blob/main/docs/reference/configuration.md), [quotas and pricing](https://github.com/google-gemini/gemini-cli/blob/main/docs/resources/quota-and-pricing.md), [sandboxing](https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/sandbox.md), [policy engine](https://github.com/google-gemini/gemini-cli/blob/main/docs/reference/policy-engine.md), [troubleshooting](https://github.com/google-gemini/gemini-cli/blob/main/docs/resources/troubleshooting.md), [headless mode](https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/headless.md), [session management](https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/session-management.md)
- Gemini CLI v0.67.0 source: [ProQuotaDialog.tsx](https://github.com/google-gemini/gemini-cli/blob/v0.67.0/packages/cli/src/ui/components/ProQuotaDialog.tsx), [useQuotaAndFallback.ts](https://github.com/google-gemini/gemini-cli/blob/v0.67.0/packages/cli/src/ui/hooks/useQuotaAndFallback.ts), [useGeminiStream.ts](https://github.com/google-gemini/gemini-cli/blob/v0.67.0/packages/cli/src/ui/hooks/useGeminiStream.ts)
- google-gemini/gemini-cli: [#24937 (capacity, open)](https://github.com/google-gemini/gemini-cli/issues/24937), [#30182 (network hang fix)](https://github.com/google-gemini/gemini-cli/pull/30182), [#29830 (out of memory)](https://github.com/google-gemini/gemini-cli/issues/29830), [#30180 (its fix)](https://github.com/google-gemini/gemini-cli/pull/30180), [#28598 (Seatbelt crash, open)](https://github.com/google-gemini/gemini-cli/issues/28598)
- Apple: [QA1340](https://developer.apple.com/library/archive/qa/qa1340/_index.html), [sleep and wake settings (macOS Tahoe 26)](https://support.apple.com/guide/mac-help/mchle41a6ccd/26/mac/26), [external displays](https://support.apple.com/en-us/102501)
