---
title: How to keep Cline running with the MacBook lid closed
description: Cline stops when the Mac sleeps, and closing the lid sleeps a MacBook. Keep Mac Awake keeps Cline working with the lid closed and no external display.
date: 2026-11-07
kicker: Cline
section: Agents and remote control
related: keep-claude-code-running-lid-closed, run-ai-agents-overnight-macbook, steer-ai-agents-from-your-phone
---

> **Short answer:** Cline runs its agent on your Mac, in Cline Desktop, the editor extension or the Cline CLI, so a task stops when the Mac sleeps. Closing a MacBook's lid puts it to sleep. As of November 2026, Cline's docs describe no setting that keeps the computer awake; a request for one in Cline Desktop is open, and the proposed change targets idle sleep, which does not cover the lid. To keep Cline working with the lid closed, the first choice is a Keep Mac Awake session such as `keepmacawake start --hours 8`: it keeps a MacBook with Apple silicon on macOS 26 or later awake with no external display, then restores normal sleep.

## Where does Cline run its tasks?

On your computer, whichever way you use it. As of November 2026, Cline comes as a desktop app, an extension for VS Code, Cursor, JetBrains and other editors, a CLI, a Kanban board and an SDK ([installing Cline](https://docs.cline.bot/getting-started/installing-cline)). In each, by default, the agent reads files, runs commands and calls the model from the machine it is installed on, so it works only while that machine is awake.

The CLI adds work that runs without you. "Scheduled agents persist across process restarts and run independently of any terminal session" ([scheduling](https://docs.cline.bot/cli/scheduling)), and connectors let you message the agent from Telegram, Slack or WhatsApp: "Each incoming message creates or continues an agent session" ([connectors](https://docs.cline.bot/cli/connectors)). Both still run on your Mac, through a background process the docs call the hub, a "Singleton daemon per machine" ([hub and spoke](https://docs.cline.bot/sdk/architecture/hub-spoke)).

## Why does Cline stop when the MacBook lid closes?

Closing the lid puts the Mac to sleep, and a sleeping Mac runs no agent. 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)). The task freezes until the Mac wakes.

Idle sleep stops it too: with the lid open, a Mac sleeps after a period of inactivity ([Apple Support, macOS Tahoe 26](https://support.apple.com/guide/mac-help/mchle41a6ccd/26/mac/26)). A feature request for Cline Desktop describes it: "the OS enters idle sleep because there is no user input and no power assertion is registered. The process is frozen and network connections drop mid-task" ([cline/cline #14297](https://github.com/cline/cline/issues/14297)).

Scheduled tasks are affected as well: a pull request describes a user who "put their computer to sleep mid-run, and came back to ~4 sessions all executing the same task" ([#13745](https://github.com/cline/cline/pull/13745), open as of November 2026). A related fix that was merged says of itself: "This does not keep a sleeping laptop awake or move execution to the cloud" ([#14004](https://github.com/cline/cline/pull/14004)).

## Does Cline have a keep awake setting?

Not as of November 2026. Cline's docs describe no setting that keeps the computer awake, and request #14297 (September 2026) is open. A pull request that would add one to Cline Desktop, #14335, is also open; on macOS it would hold the IOKit PreventUserIdleSystemSleep assertion while a task runs ([#14335](https://github.com/cline/cline/pull/14335)).

That assertion prevents idle sleep only. Apple: "The system may still sleep for lid close, Apple menu, low battery, or other sleep reasons" ([Apple developer docs](https://developer.apple.com/documentation/iokit/kiopmassertiontypepreventuseridlesystemsleep)). So even once it ships, closing the lid would still put the MacBook to sleep. The request names today's workaround: running caffeinate by hand or a third-party keep-awake tool.

## How do you keep Cline running with the lid closed?

The first choice is a Keep Mac Awake session, which keeps the MacBook itself awake for the hours you pick. As of November 2026:

| Option | Closed MacBook, nobody there | Needs | Watch out for |
| --- | --- | --- | --- |
| Keep Mac Awake | Stays awake for the session | Apple silicon, macOS 26 or later | AC power unless you allow battery; never starts by itself |
| External display (closed-display mode) | Stays awake | Power, display, keyboard and mouse | Sleeps if the display disconnects |
| `caffeinate -s` in Terminal | Dark wake while it runs, on AC power | The caffeinate process kept running | On battery the lid sleeps the Mac |
| `sudo pmset disablesleep 1` | Stays awake | Administrator password | No timer; undo with `sudo pmset disablesleep 0` |
| Cline Desktop over SSH to another host | The host keeps working; the MacBook may sleep | A second machine you can reach by SSH | Approvals and output stay in the app on your Mac |

caffeinate -s is the one caffeinate flag that holds a closed MacBook, and only on AC power: Apple says its assertion "allows the system to reside in Dark Wake for an arbitrary length of time" ([Apple developer docs](https://developer.apple.com/documentation/iokit/kiopmassertiontypepreventsystemsleep)), and the man page says it is "valid only when system is running on AC power" ([man caffeinate](https://github.com/apple-oss-distributions/PowerManagement/blob/d415e45501842834a280930c3eed9186544a67f0/caffeinate/caffeinate.8)); the flag by flag detail is in [does caffeinate work with the lid closed](/blog/caffeinate-lid-closed). With a display, Apple says the closed Mac must be "connected to power and using an external keyboard and mouse" ([Apple Support](https://support.apple.com/en-us/102501)). Cline Desktop can run sessions on another machine: "every session you start runs on that host", while "the chat, approvals, and live output stay in the app on your computer" ([Cline Desktop over SSH](https://docs.cline.bot/usage/cline-desktop-ssh)).

## What to use

To keep Cline running with the MacBook lid 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 --json`, and restores normal sleep when a timed session ends.

A session lasts as long as you pick: no limit, 1 hour, 8 hours or a custom number of hours up to 168, so scheduled runs and connector messages find the Mac awake through the night. It runs on AC power by default, and battery use is optional, down to a floor you pick. A separate watchdog restores the normal sleep setting if Keep Mac Awake's background service or the system service stops or hangs. It keeps the Mac awake, nothing more: it does not keep Wi-Fi alive, does not wake a Mac that is already asleep and approves nothing for Cline. More on the app: [keep a MacBook awake with the lid closed](/).

Cline can run the command itself: ask it to start `keepmacawake start --hours 8 --json` before a long task and `keepmacawake stop --json` at the end. Each call returns one JSON object and a documented exit code, listed in the [agent guide](https://keepmacawake.com/agents.md).

Other options, with the limits in the table: an external display with power, keyboard and mouse; caffeinate -s, on AC power while the caffeinate process runs; or `sudo pmset disablesleep 1`, with no timer, until you set it back to 0 ([what pmset disablesleep does](/blog/pmset-disablesleep)).

A closed MacBook still makes heat: keep it on a hard surface with airflow, never in a bag or under a pillow ([MacBook heat and battery with the lid closed](/blog/macbook-lid-closed-heat-and-battery)). Why the lid stops every app, not only Cline, is in [keep a MacBook from sleeping with the lid closed](/blog/prevent-macbook-sleep-lid-closed).

## Why does Cline keep stopping?

Usually sleep, a waiting approval, a network drop or a run limit. Unless auto-approve covers an action, Cline asks before it acts ([auto approve](https://docs.cline.bot/features/auto-approve)), so a task you leave can sit on its first command; a scheduled run approves its own tool calls "because nobody is there to approve them" ([scheduling](https://docs.cline.bot/cli/scheduling)). Connectors carry a warning worth reading before you leave one running: "By default, anyone who finds your bot can message it and it will execute tasks on your machine" ([connectors](https://docs.cline.bot/cli/connectors)). Keep Mac Awake does not keep Wi-Fi, a VPN or Tailscale connected. The checklist for a night alone is in [run AI coding agents overnight on a MacBook](/blog/run-ai-agents-overnight-macbook), and the closed-lid setup for Claude Code is in [keep Claude Code running with the lid closed](/blog/keep-claude-code-running-lid-closed).

## FAQ

### Does Cline keep running when I close my MacBook?

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

### Do Cline scheduled tasks run while my Mac is asleep?

No. Cline's hub, a process on your Mac, starts them, and they run on the Mac too, so a sleeping Mac runs none of them. Keep the Mac awake for the hours the schedule covers; the first choice with the lid closed is a Keep Mac Awake session.

### Will Cline's proposed keep awake setting work with the lid closed?

The proposal holds an idle-sleep assertion, and Apple says the system may still sleep for lid close with that assertion held. For the lid, the first choice is a Keep Mac Awake session.

### Can I message Cline from my phone while the MacBook is closed?

Yes, through a connector such as Telegram, while the Mac stays awake and online and the connector keeps running; with the lid closed, start a Keep Mac Awake session first. Other ways to reach agents from a phone are in [control AI coding agents from your phone](/blog/steer-ai-agents-from-your-phone).

## Sources

- Cline docs: [installing Cline](https://docs.cline.bot/getting-started/installing-cline), [scheduling](https://docs.cline.bot/cli/scheduling), [connectors](https://docs.cline.bot/cli/connectors), [hub and spoke](https://docs.cline.bot/sdk/architecture/hub-spoke), [Cline Desktop over SSH](https://docs.cline.bot/usage/cline-desktop-ssh), [auto approve](https://docs.cline.bot/features/auto-approve)
- [cline/cline #14297: prevent system sleep while a task is running (feature request)](https://github.com/cline/cline/issues/14297)
- [cline/cline #14335: prevent system sleep while a task is running (open pull request)](https://github.com/cline/cline/pull/14335)
- [cline/cline #13745: duplicate scheduled sessions after sleep (open pull request)](https://github.com/cline/cline/pull/13745)
- [cline/cline #14004: schedule polling fixes (merged pull request)](https://github.com/cline/cline/pull/14004)
- [man caffeinate](https://github.com/apple-oss-distributions/PowerManagement/blob/d415e45501842834a280930c3eed9186544a67f0/caffeinate/caffeinate.8)
- Apple: [QA1340](https://developer.apple.com/library/archive/qa/qa1340/_index.html), [idle sleep assertion](https://developer.apple.com/documentation/iokit/kiopmassertiontypepreventuseridlesystemsleep), [system sleep assertion](https://developer.apple.com/documentation/iokit/kiopmassertiontypepreventsystemsleep), [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)
