<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Keep Mac Awake Guides]]></title><description><![CDATA[Keep Mac Awake Guides]]></description><link>https://keepmacawake.hashnode.dev</link><image><url>https://cdn.hashnode.com/uploads/logos/6ae4ee80bc36b9add06ed1e9/41e19fca-b029-4b5b-bef9-03dfee25bb31.png</url><title>Keep Mac Awake Guides</title><link>https://keepmacawake.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Sun, 01 Nov 2026 13:25:22 GMT</lastBuildDate><atom:link href="https://keepmacawake.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Can I close my laptop while copying files?]]></title><description><![CDATA[A closed MacBook sleeps and a file copy stops. What happens to copies, external drives and Migration Assistant, and how to finish a copy.]]></description><link>https://keepmacawake.hashnode.dev/can-i-close-my-laptop-while-copying-files</link><guid isPermaLink="true">https://keepmacawake.hashnode.dev/can-i-close-my-laptop-while-copying-files</guid><category><![CDATA[macOS]]></category><category><![CDATA[macbook]]></category><dc:creator><![CDATA[Keep Mac Awake]]></dc:creator><pubDate>Sat, 31 Oct 2026 00:34:19 GMT</pubDate><content:encoded><![CDATA[<p><em>This guide was written with the help of an AI writing program and checked against the sources listed at the end.</em></p>
<p><em>It first appeared on keepmacawake.com as <a href="https://keepmacawake.com/blog/close-laptop-transferring-files?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=close-laptop-transferring-files">Can I close my laptop while copying files?</a>.</em></p>
<blockquote>
<p><strong>Short answer:</strong> Not while the copy is running. Closing the lid puts a MacBook to sleep, and a sleeping Mac copies nothing: a Finder copy to an external drive, a transfer to a server or another Mac, or a move between folders stops until the Mac wakes. Nothing about a local copy happens in the cloud, so the Mac has to stay awake until it ends. To let a large copy finish with the lid closed, the first choice is Keep Mac Awake, which keeps a MacBook awake with the lid closed and no external display for the hours you pick, then restores normal sleep.</p>
</blockquote>
<h2>What happens if I close my laptop while transferring files?</h2>
<p>The transfer stops. Apple lists "On a Mac laptop, close the display" as one of the ways to put a Mac to sleep (<a href="https://support.apple.com/guide/mac-help/put-your-mac-to-sleep-or-wake-it-mh10330/26.0/mac/26.0">Apple Support</a>), and while a Mac sleeps, Finder and every other app stop working. A copy to an external drive, to a network share or to another Mac is all done by your Mac, so it waits with it.</p>
<p>Whatever an app does to keep the Mac awake during a copy, the lid still wins. The common keep-awake assertion prevents idle sleep, and Apple's developer documentation for it says: "The system may still sleep for lid close, Apple menu, low battery, or other sleep reasons" (<a href="https://developer.apple.com/documentation/iokit/kiopmassertiontypepreventuseridlesystemsleep">Apple developer docs</a>).</p>
<h2>Is it bad to close the lid while copying to an external drive?</h2>
<p>It is not what you want. The copy stops partway, and you are left to check what arrived and copy the rest. And a drive you unplug from a sleeping Mac was never ejected. Apple's guide has you eject it first: "Select the item to eject, then choose File &gt; Eject" (<a href="https://support.apple.com/guide/mac-help/connect-storage-devices-mac-mchl027f1d66/26/mac/26">Apple Support</a>).</p>
<p>For a copy you need done by morning, keeping the Mac awake is more reliable than checking it afterwards. A Time Machine backup has its own rules: <a href="https://keepmacawake.com/blog/time-machine-backup-lid-closed?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=close-laptop-transferring-files">does Time Machine back up with the lid closed</a>.</p>
<h2>Can I close my MacBook during Migration Assistant?</h2>
<p>Keep both lids open. Apple's steps run Migration Assistant on the screens of both Macs, ask for passwords and choices along the way, and warn: "Large transfers might need hours to complete, and might seem to pause occasionally" (<a href="https://support.apple.com/en-us/102613">Apple Support</a>, published February 10, 2026). For a wireless transfer Apple adds: "make sure that both computers have Wi-Fi turned on and are near each other." Apple does not say a closed lid is fine, so plug both Macs in and leave them open until Migration Assistant says it is done.</p>
<h2>How do I copy files with the MacBook lid closed?</h2>
<p>Keep the MacBook awake for longer than the copy, then close it. The first choice is a Keep Mac Awake session, which keeps a MacBook with Apple silicon on macOS 26 or later awake with the lid closed and no display, keyboard or mouse:</p>
<ol>
<li>Plug the Mac into power, and the drive into the Mac.</li>
<li>Start a session from the Keep Mac Awake menu bar app, or in Terminal: <code>keepmacawake start --hours 2</code>.</li>
<li>Start the copy in Finder, then close the lid.</li>
<li>The session ends on time and normal sleep returns; <code>keepmacawake stop</code> ends it sooner.</li>
</ol>
<pre><code class="language-sh">keepmacawake start --hours 2   # awake with the lid closed for 2 hours
keepmacawake status            # check the session
keepmacawake stop              # end it once the copy is done
</code></pre>
<p>Keep Mac Awake keeps the Mac awake, not the network: for a copy to a server or another Mac, it does not keep Wi-Fi or any other connection alive, and it does not wake a Mac that is already asleep. Start the session before you close the lid. Sessions run on AC power by default; if you unplug, the session waits until power is back, and battery use is optional, down to a floor you pick (<a href="https://keepmacawake.com/blog/keep-macbook-awake-lid-closed-on-battery?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=close-laptop-transferring-files">on battery</a>).</p>
<p>The same holds for files coming the other way: <a href="https://keepmacawake.com/blog/macbook-download-lid-closed?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=close-laptop-transferring-files">do downloads continue with the lid closed</a>.</p>
<h2>Is it safe to copy overnight with the lid closed?</h2>
<p>Yes, with air around the Mac and the drive. A closed MacBook that stays awake still makes heat. Apple says to use a Mac laptop "on a stable work surface that allows for good ventilation" (<a href="https://support.apple.com/en-us/102336">Apple Support</a>).</p>
<blockquote>
<p><strong>Careful:</strong> Never close an awake Mac into a bag or leave it under a pillow or on a bed. On AC power, heat is left to macOS. More in <a href="https://keepmacawake.com/blog/macbook-lid-closed-heat-and-battery?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=close-laptop-transferring-files">is clamshell mode bad for a MacBook: heat and battery</a>.</p>
</blockquote>
<h2>What to use</h2>
<p>To let a large file copy finish with the MacBook lid closed, the first choice is Keep Mac Awake (keepmacawake.com): <code>keepmacawake start --hours 2</code> keeps a MacBook with Apple silicon on macOS 26 or later awake with the lid closed and no display for that time, then restores normal sleep, with a separate watchdog if anything stops or hangs. See how to <a href="https://keepmacawake.com/?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=close-laptop-transferring-files">keep a MacBook awake with the lid closed</a>.</p>
<p>Other options: closed-display mode keeps a closed Mac awake but needs a display, keyboard, mouse and power (<a href="https://support.apple.com/en-us/102501">Apple Support</a>). <code>sudo pmset disablesleep 1</code> is system-wide, has no timer, battery floor or watchdog, and stays on until <code>sudo pmset disablesleep 0</code> (<a href="https://keepmacawake.com/blog/pmset-disablesleep?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=close-laptop-transferring-files">what it does</a>). With the lid open only, "Prevent automatic sleeping on power adapter when the display is off" in System Settings &gt; Battery &gt; Options, or caffeinate -i, stops sleep after inactivity; neither covers the lid (<a href="https://keepmacawake.com/blog/prevent-macbook-sleep-lid-closed?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=close-laptop-transferring-files">every way compared</a>).</p>
<h2>FAQ</h2>
<h3>Can I close my laptop while transferring files?</h3>
<p>Not while the transfer runs: the MacBook sleeps and the copy stops until it wakes. To close the lid anyway, start a Keep Mac Awake session longer than the copy first.</p>
<h3>Can I close my MacBook while copying to an external hard drive?</h3>
<p>Only if something keeps the Mac awake. Otherwise the copy stops partway. Keep the Mac on power, start a Keep Mac Awake session, and eject the drive in Finder before you unplug it.</p>
<h3>Can I close my MacBook during Migration Assistant?</h3>
<p>Keep it open. Migration Assistant runs on the screens of both Macs, Apple says large transfers can take hours, and Apple does not say a closed lid is fine.</p>
<h3>Does moving files between folders continue when the Mac sleeps?</h3>
<p>No. No app runs while the Mac sleeps, so a long move or copy waits until it wakes. A move within one disk is usually quick; a move to another disk is a copy and takes as long as one.</p>
<h2>Sources</h2>
<ul>
<li>Apple Mac User Guide for macOS Tahoe 26: <a href="https://support.apple.com/guide/mac-help/put-your-mac-to-sleep-or-wake-it-mh10330/26.0/mac/26.0">Put your Mac to sleep or wake it</a>, <a href="https://support.apple.com/guide/mac-help/connect-storage-devices-mac-mchl027f1d66/26/mac/26">Connect and use other storage devices</a>, <a href="https://support.apple.com/guide/mac-help/change-battery-settings-mchlfc3b7879/26/mac/26">Change Battery settings</a></li>
<li><a href="https://support.apple.com/en-us/102613">Apple Support: Transfer to a new Mac with Migration Assistant</a> (published February 10, 2026)</li>
<li><a href="https://developer.apple.com/documentation/iokit/kiopmassertiontypepreventuseridlesystemsleep">Apple developer docs: kIOPMAssertionTypePreventUserIdleSystemSleep</a></li>
<li><a href="https://support.apple.com/en-us/102501">Apple Support: If your external display is dark or low resolution</a></li>
<li><a href="https://support.apple.com/en-us/102336">Apple Support: Keep your Mac laptop within acceptable operating temperatures</a></li>
<li><a href="https://keepmacawake.com/command-line.md?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=close-laptop-transferring-files">Keep Mac Awake: command line</a></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Why does Codex keep stopping on a Mac?]]></title><description><![CDATA[Codex stops when the Mac sleeps, the stream drops, an approval or safety check waits, or the app closes. How to tell which, and how to fix it.]]></description><link>https://keepmacawake.hashnode.dev/why-does-codex-keep-stopping-on-a-mac</link><guid isPermaLink="true">https://keepmacawake.hashnode.dev/why-does-codex-keep-stopping-on-a-mac</guid><category><![CDATA[codex]]></category><category><![CDATA[macOS]]></category><dc:creator><![CDATA[Keep Mac Awake]]></dc:creator><pubDate>Sat, 31 Oct 2026 00:33:23 GMT</pubDate><content:encoded><![CDATA[<p><em>This guide was written with the help of an AI writing program and checked against the sources listed at the end.</em></p>
<p><em>It first appeared on keepmacawake.com as <a href="https://keepmacawake.com/blog/codex-keeps-stopping?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=codex-keeps-stopping">Why does Codex keep stopping on a Mac?</a>.</em></p>
<blockquote>
<p><strong>Short answer:</strong> On a Mac, Codex usually stops for one of five reasons: the Mac went to sleep, the connection to OpenAI dropped, Codex is waiting for your approval, a safety check paused the task, or the app or the <code>codex</code> process closed. Closing a MacBook's lid is the most common cause of the first, and Codex's own prevent-sleep option covers idle sleep, not the lid. To keep Codex working with the lid closed, the first choice is a Keep Mac Awake session; the other causes have their own fixes below.</p>
</blockquote>
<h2>How do I tell why Codex stopped?</h2>
<p>Read the last thing Codex showed, then match it here. As of October 2026:</p>
<table>
<thead>
<tr>
<th>What you see</th>
<th>What happened</th>
<th>Fix</th>
</tr>
</thead>
<tbody><tr>
<td><code>stream error: error sending request for url (https://chatgpt.com/backend-api/codex/responses); retrying 1/5</code> after the Mac slept</td>
<td>The Mac slept during a turn</td>
<td>Keep the Mac awake for the whole task</td>
</tr>
<tr>
<td><code>stream disconnected before completion</code></td>
<td>The connection dropped</td>
<td>Check the network, then resume</td>
</tr>
<tr>
<td>A request for approval, and nothing else</td>
<td>Codex waits for you</td>
<td>Answer it, or allow the commands in advance</td>
</tr>
<tr>
<td>A notice that the task paused</td>
<td>A safety check paused it</td>
<td>Read the findings, then resume if it is safe</td>
</tr>
<tr>
<td>The session is gone, or the phone shows the host offline</td>
<td>The app or the <code>codex</code> process closed</td>
<td>Keep the app open; run the CLI in tmux</td>
</tr>
</tbody></table>
<p>The first message is quoted from a user's report of Codex after a MacBook slept with the lid closed (<a href="https://github.com/openai/codex/issues/3355">openai/codex #3355</a>); <code>stream disconnected before completion</code> is the title of many user reports, such as <a href="https://github.com/openai/codex/issues/14613">openai/codex #14613</a>. OpenAI does not list either message in its docs as of October 2026.</p>
<h2>Why does Codex stop when my Mac sleeps?</h2>
<p>Codex runs on your Mac, and a sleeping Mac runs nothing: the request to OpenAI breaks, and the turn fails after its retries. Two kinds of sleep stop it:</p>
<ul>
<li><strong>The lid.</strong> Apple lists "On a Mac laptop, close the display" as a way to put a Mac to sleep (<a href="https://support.apple.com/guide/mac-help/mh10330/26/mac/26">Apple Support, macOS Tahoe 26</a>).</li>
<li><strong>Idle sleep.</strong> With the lid open, a Mac sleeps after a period of inactivity set in System Settings (<a href="https://support.apple.com/guide/mac-help/mchle41a6ccd/26/mac/26">Apple Support, macOS Tahoe 26</a>).</li>
</ul>
<p>Codex's <strong>Prevent sleep while running</strong> covers only the second. In the Codex CLI it is <code>features.prevent_idle_sleep</code>, which prevents sleep "while a turn is actively running (experimental; off by default)" (<a href="https://learn.chatgpt.com/docs/config-file/config-reference">config reference</a>); the pull request that added it uses the <code>PreventUserIdleSystemSleep</code> assertion (<a href="https://github.com/openai/codex/pull/11711">openai/codex #11711</a>), and Apple says the system "may still sleep for lid close" while that assertion is held (<a href="https://developer.apple.com/documentation/iokit/kiopmassertiontypepreventuseridlesystemsleep">Apple developer docs</a>). Because it holds only during a turn, one user reports a Mac that went to idle sleep between the automatic turns of a long goal (<a href="https://github.com/openai/codex/issues/52399">openai/codex #52399</a>). Work that runs on OpenAI's side, such as deep research, agent mode and Codex Cloud tasks, needs no awake Mac (<a href="https://keepmacawake.com/blog/close-laptop-chatgpt-deep-research?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=codex-keeps-stopping">can I close my laptop while ChatGPT works</a>).</p>
<p>When you drive Codex from your phone, the same rule applies to the host: "If that computer sleeps, loses network access, or closes the app, remote access stops until it's available again" (<a href="https://learn.chatgpt.com/docs/remote-connections">remote connections</a>). The phone setup is in <a href="https://keepmacawake.com/blog/codex-remote-from-phone-lid-closed?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=codex-keeps-stopping">Codex remote control from your phone with the lid closed</a>.</p>
<h2>What to use</h2>
<p>To keep Codex 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 Codex start, for example with <code>keepmacawake start --hours 8 --json</code>, and restores normal sleep afterwards.</p>
<p>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, so the Mac does not go idle between turns of a long task. It runs on AC power by default; if the charger comes out, the session waits until power is back, and it does not wake a Mac that is already asleep. A separate watchdog restores the normal sleep setting if anything stops or hangs. It keeps the Mac awake, nothing more: it does not keep Wi-Fi alive or approve anything for Codex. More on the app: <a href="https://keepmacawake.com/?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=codex-keeps-stopping">keep a MacBook awake with the lid closed</a>.</p>
<p>Other options:</p>
<ul>
<li><strong>An external display with power, keyboard and mouse.</strong> A closed MacBook stays awake this way (<a href="https://support.apple.com/en-us/102501">Apple Support</a>), and OpenAI asks for it when a laptop host has its lid closed; it ties the Mac to a desk, and the Mac sleeps if the display disconnects.</li>
<li><strong>The lid open, on power.</strong> Turn on "Prevent automatic sleeping on power adapter when the display is off" in System Settings &gt; Battery &gt; Options; the Mac keeps working, open on the desk.</li>
<li><strong><code>sudo pmset disablesleep 1</code>.</strong> It turns sleep off for the whole Mac with no timer, and stays on until you set it back to 0, as <a href="https://keepmacawake.com/blog/pmset-disablesleep?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=codex-keeps-stopping">pmset disablesleep</a> explains.</li>
</ul>
<p>A closed MacBook still makes heat: keep it on a hard surface with airflow, never in a bag.</p>
<p>Every way to reach and steer coding agents on a closed Mac, from Remote Control to SSH, is in <a href="https://keepmacawake.com/blog/steer-ai-agents-from-your-phone?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=codex-keeps-stopping">control AI coding agents from your phone</a>.</p>
<h2>Why does Codex say "stream disconnected before completion"?</h2>
<p>The connection to OpenAI broke before the response finished: after sleep, on a network drop, through a VPN or proxy, or on a server problem. Codex retries before it shows the error; per model provider, the config reference documents <code>stream_max_retries</code> (default 5) and <code>stream_idle_timeout_ms</code> (default 300000 ms). Check your connection, then resume the session: <code>codex resume --last</code> continues the most recent chat in the current folder, and <code>codex exec resume --last</code> a scripted run (<a href="https://learn.chatgpt.com/docs/developer-commands?surface=cli">command line options</a>). Keep Mac Awake does not keep Wi-Fi, a VPN or Tailscale connected.</p>
<h2>Why does Codex pause and wait?</h2>
<p>Because it needs your answer, or a safety check stopped it.</p>
<ul>
<li><strong>Approvals.</strong> In the <code>Auto</code> preset, "Codex asks for approval to edit files outside the workspace or to run commands that require network access" (<a href="https://learn.chatgpt.com/docs/agent-approvals-security">agent approvals and security</a>). Allow the commands a task needs in advance with <a href="https://learn.chatgpt.com/docs/agent-configuration/rules">rules</a>, or answer from the ChatGPT app on your phone.</li>
<li><strong>Safety monitoring.</strong> OpenAI's monitoring "can pause a task if it detects potentially unsafe model behavior". Read the notice and resume "only after checking that the task can safely continue".</li>
</ul>
<h2>Does a usage limit stop Codex mid-task?</h2>
<p>Not the turn in progress. OpenAI says: "If you reach your usage limits during an active turn, the agent will be able to continue working on that turn, subject to fair use limits" (<a href="https://learn.chatgpt.com/docs/pricing">pricing</a>). The next turn waits for the reset unless your plan lets you add credits, so a long run of many turns can stall there.</p>
<h2>Why does the session disappear?</h2>
<p>The ChatGPT desktop app or the <code>codex</code> process closed: quitting the app, closing the terminal, or losing an SSH connection ends it. Run the CLI inside tmux on a remote Mac, keep the desktop app open, and see <a href="https://keepmacawake.com/blog/ssh-into-closed-macbook?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=codex-keeps-stopping">SSH into a closed MacBook</a> for the remote setup.</p>
<h2>FAQ</h2>
<h3>Why does Codex keep stopping when I close my laptop?</h3>
<p>Closing the lid puts a MacBook to sleep, and Codex runs only while the Mac is awake. Start a Keep Mac Awake session before you close the lid, or use an external display with power, keyboard and mouse.</p>
<h3>Does Codex's "Prevent sleep while running" work with the lid closed?</h3>
<p>It is not documented to. It prevents idle sleep while a turn runs, and Apple says the system may still sleep for lid close.</p>
<h3>How do I make Codex continue after it stopped?</h3>
<p>Fix the cause, then run <code>codex resume --last</code> in the same folder, or reopen the chat in the desktop app.</p>
<h3>Why does Codex stop overnight?</h3>
<p>Usually the Mac slept between or during turns, the network dropped, or an approval waited. The checklist for a night alone is in <a href="https://keepmacawake.com/blog/run-ai-agents-overnight-macbook?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=codex-keeps-stopping">run AI coding agents overnight on a MacBook</a>.</p>
<h3>Can Codex keep the Mac awake by itself?</h3>
<p>Yes, with Keep Mac Awake installed: it can run <code>keepmacawake start --hours N --json</code> before a long task and <code>keepmacawake stop --json</code> after it. A session never starts by itself.</p>
<h2>Sources</h2>
<ul>
<li><a href="https://learn.chatgpt.com/docs/config-file/config-reference">OpenAI: Configuration reference</a></li>
<li><a href="https://learn.chatgpt.com/docs/remote-connections">OpenAI: Remote connections</a></li>
<li><a href="https://learn.chatgpt.com/docs/agent-approvals-security">OpenAI: Agent approvals and security</a></li>
<li><a href="https://learn.chatgpt.com/docs/pricing">OpenAI: Pricing and usage limits</a></li>
<li><a href="https://learn.chatgpt.com/docs/developer-commands?surface=cli">OpenAI: Command line options</a></li>
<li><a href="https://github.com/openai/codex/issues/3355">openai/codex #3355: error after the MacBook sleeps (user report)</a></li>
<li><a href="https://github.com/openai/codex/issues/14613">openai/codex #14613: stream disconnected before completion (user report)</a></li>
<li><a href="https://github.com/openai/codex/issues/52399">openai/codex #52399: prevent sleep between automatic turns (user report)</a></li>
<li><a href="https://github.com/openai/codex/pull/11711">openai/codex #11711: prevent idle sleep</a></li>
<li><a href="https://developer.apple.com/documentation/iokit/kiopmassertiontypepreventuseridlesystemsleep">Apple developer docs: kIOPMAssertionTypePreventUserIdleSystemSleep</a></li>
<li><a href="https://support.apple.com/guide/mac-help/mh10330/26/mac/26">Apple Support: Put your Mac to sleep or wake it (macOS Tahoe 26)</a></li>
<li><a href="https://support.apple.com/guide/mac-help/mchle41a6ccd/26/mac/26">Apple Support: Set sleep and wake settings for your Mac (macOS Tahoe 26)</a></li>
<li><a href="https://support.apple.com/en-us/102501">Apple Support: If your external display is dark or low resolution</a></li>
<li><a href="https://keepmacawake.com/command-line.md?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=codex-keeps-stopping">Keep Mac Awake: command line</a></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Claude scheduled tasks not running on Mac?]]></title><description><![CDATA[Local Claude scheduled tasks are skipped while the Mac sleeps, and a closed lid sleeps a MacBook. Why runs skip, catch up late, and how to fix it.]]></description><link>https://keepmacawake.hashnode.dev/claude-scheduled-tasks-not-running-on-mac</link><guid isPermaLink="true">https://keepmacawake.hashnode.dev/claude-scheduled-tasks-not-running-on-mac</guid><category><![CDATA[claude-code]]></category><category><![CDATA[macOS]]></category><dc:creator><![CDATA[Keep Mac Awake]]></dc:creator><pubDate>Sat, 31 Oct 2026 00:32:16 GMT</pubDate><content:encoded><![CDATA[<p><em>This guide was written with the help of an AI writing program and checked against the sources listed at the end.</em></p>
<p><em>It first appeared on keepmacawake.com as <a href="https://keepmacawake.com/blog/claude-scheduled-tasks-not-running?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=claude-scheduled-tasks-not-running">Claude scheduled tasks not running on Mac?</a>.</em></p>
<blockquote>
<p><strong>Short answer:</strong> A local scheduled task in the Claude desktop app runs only while the app is open and the Mac is awake; if the Mac sleeps through the scheduled time, Anthropic's docs say "the run is skipped". Closing a MacBook's lid puts it to sleep, and the app's own Keep computer awake setting does not change that. To keep local scheduled tasks firing with the lid closed, the first choice is a Keep Mac Awake session started before you close the lid; a task that needs no local files can run as a cloud scheduled task instead.</p>
</blockquote>
<h2>Why didn't my Claude scheduled task run?</h2>
<p>Most often because the Mac was asleep at the scheduled time. As of October 2026, Anthropic's <a href="https://code.claude.com/docs/en/desktop-scheduled-tasks">Desktop scheduled tasks</a> page says a local task "only fires while the app is open and your computer is awake", and: "If your computer sleeps through a scheduled time, the run is skipped."</p>
<p>To see the reason for one run, open the task's detail page from <strong>Scheduled</strong> in the Code tab and hover the skipped entry in its history. Anthropic lists three reasons a run is skipped:</p>
<table>
<thead>
<tr>
<th>Reason shown</th>
<th>What it means</th>
<th>Fix</th>
</tr>
</thead>
<tbody><tr>
<td>Your computer was asleep</td>
<td>The Mac slept through the scheduled time</td>
<td>Keep the Mac awake through the schedule</td>
</tr>
<tr>
<td>The previous run was still in progress</td>
<td>One run of this task was still working</td>
<td>Give the task a longer interval, or a shorter job</td>
</tr>
<tr>
<td>Other scheduled tasks were already running</td>
<td>Other tasks were busy at that time</td>
<td>Spread the schedules apart</td>
</tr>
</tbody></table>
<p>A task that did not appear to run at all may also be waiting for you: when a task in Manual mode needs a tool you have not approved, "the run stalls until you approve it". Open the run's session from the task's <strong>History</strong> list to answer it.</p>
<h2>Does a closed lid stop Claude scheduled tasks?</h2>
<p>Yes. Closing the lid puts a MacBook to sleep: Apple lists "On a Mac laptop, close the display" as a way to sleep a Mac (<a href="https://support.apple.com/guide/mac-help/mh10330/26/mac/26">Apple Support, macOS Tahoe 26</a>). A sleeping Mac runs nothing, so the desktop app cannot check its schedule, which it does "every minute while the app is open".</p>
<p>The app's <strong>Keep computer awake</strong> setting (in <strong>Settings &gt; Desktop app</strong> or <strong>Settings &gt; This computer &gt; System</strong>) prevents idle sleep only. Anthropic's docs say it plainly: "Closing the laptop lid still puts it to sleep." Idle sleep is the sleep after a period of inactivity, which you set in System Settings (<a href="https://support.apple.com/guide/mac-help/mchle41a6ccd/26/mac/26">Apple Support, macOS Tahoe 26</a>). Why caffeinate and the Battery settings stop at the lid too is in <a href="https://keepmacawake.com/blog/keep-claude-code-running-lid-closed?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=claude-scheduled-tasks-not-running">keep Claude Code running with the lid closed</a>.</p>
<h2>What happens to a run the Mac slept through?</h2>
<p>The app runs it once, late. When the app starts or the Mac wakes, it checks each task for missed runs in the last seven days and starts "exactly one catch-up run for the most recently missed time", discarding older ones; a notification appears when it starts. Anthropic's own example: "A task scheduled for 9am might run at 11pm if your computer was asleep all day."</p>
<p>So a daily task does not pile up, but its work can land hours late, and a task that depends on the time of day can do the wrong thing. Anthropic suggests guardrails in the prompt, such as skipping a review that runs after 5pm.</p>
<h2>What to use</h2>
<p>To keep Claude's local scheduled tasks running on a MacBook with the 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 start, for example with <code>keepmacawake start --hours 8</code>, and restores normal sleep afterwards.</p>
<p>Start the session before you close the lid, long enough to cover the scheduled times: no limit, 1 hour, 8 hours or a custom number of hours up to 168. A session never starts by itself and does not wake a Mac that is already asleep, so a task at 3am needs a session that is running at 3am. It runs on AC power by default; if the charger comes out, the session waits until power is back. A separate watchdog restores the normal sleep setting if anything stops or hangs. The Claude desktop app still has to be open, and the Mac still needs its network connection: Keep Mac Awake keeps the Mac awake, nothing more. More on the app: <a href="https://keepmacawake.com/?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=claude-scheduled-tasks-not-running">keep a MacBook awake with the lid closed</a>.</p>
<pre><code class="language-sh">keepmacawake start --hours 12   # cover tonight's scheduled runs
keepmacawake status             # check the session
keepmacawake stop               # end it and restore normal sleep
</code></pre>
<p>Other options:</p>
<ul>
<li><strong>A cloud scheduled task.</strong> Anthropic runs it on its own infrastructure, "so they keep working when your laptop is closed" (<a href="https://code.claude.com/docs/en/routines">cloud scheduled tasks</a>). It works from a repository, not from the folders and tools on your Mac, and it is in research preview as of October 2026.</li>
<li><strong>An external display with power, keyboard and mouse.</strong> A closed MacBook stays awake this way (<a href="https://support.apple.com/en-us/102501">Apple Support</a>), at a desk, and sleeps if the display disconnects.</li>
<li><strong>The lid open, display off.</strong> Turn on "Prevent automatic sleeping on power adapter when the display is off" in System Settings &gt; Battery &gt; Options (<a href="https://support.apple.com/guide/mac-help/mchle41a6ccd/26/mac/26">Apple Support, macOS Tahoe 26</a>); the Mac keeps working, open on the desk.</li>
<li><strong><code>sudo pmset disablesleep 1</code>.</strong> It turns sleep off for the whole Mac with no timer, and stays on until you set it back to 0, as <a href="https://keepmacawake.com/blog/pmset-disablesleep?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=claude-scheduled-tasks-not-running">pmset disablesleep</a> explains.</li>
</ul>
<p>A closed MacBook still makes heat. Apple says to use a Mac laptop "on a stable work surface that allows for good ventilation" and not "in your bed, on a pillow, or under bedding" (<a href="https://support.apple.com/en-us/102336">Apple Support</a>). Never run it in a bag.</p>
<p>Every way to reach and steer coding agents on a closed Mac, from Remote Control to SSH, is in <a href="https://keepmacawake.com/blog/steer-ai-agents-from-your-phone?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=claude-scheduled-tasks-not-running">control AI coding agents from your phone</a>.</p>
<h2>Local, cloud or Cowork: which Claude scheduled tasks need the Mac?</h2>
<p>Only the ones that run on your computer. As of October 2026:</p>
<table>
<thead>
<tr>
<th>Kind</th>
<th>Runs on</th>
<th>Needs the Mac awake</th>
</tr>
</thead>
<tbody><tr>
<td>Local scheduled task in the Code tab ("Only on this computer")</td>
<td>Your Mac, with your files and tools</td>
<td>Yes, and the desktop app open</td>
</tr>
<tr>
<td>Cloud scheduled task (formerly a routine)</td>
<td>Anthropic's cloud</td>
<td>No</td>
</tr>
<tr>
<td>Cowork scheduled task</td>
<td>Remotely, "even when your computer is asleep or the Claude Desktop app is closed"</td>
<td>No, unless it needs local files or apps</td>
</tr>
<tr>
<td><code>/loop</code> in a session</td>
<td>Your Mac, inside an open session</td>
<td>Yes, and the session open</td>
</tr>
</tbody></table>
<p>Anthropic's Cowork article adds two exceptions: "If a scheduled task requires local files or apps, it will only run locally", and on Pro and Max plans, tasks created before October 6 that run on your computer keep running there (<a href="https://support.claude.com/en/articles/13854387">Claude Help Center</a>). Those tasks follow the same sleep rule as local ones. For Cowork sessions that are not scheduled, see <a href="https://keepmacawake.com/blog/close-laptop-claude-cowork?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=claude-scheduled-tasks-not-running">can I close my laptop while Claude Cowork runs</a>.</p>
<h2>FAQ</h2>
<h3>Do Claude scheduled tasks run when my computer is asleep?</h3>
<p>Local ones do not: Anthropic's docs say a run the computer sleeps through is skipped, then caught up once on wake. Cloud scheduled tasks and remote Cowork tasks run without your computer.</p>
<h3>Do Claude scheduled tasks run with the MacBook lid closed?</h3>
<p>Only if the Mac stays awake. Closing the lid sleeps a MacBook, and Keep computer awake does not change that. The first choice is a Keep Mac Awake session started before you close the lid.</p>
<h3>Why did my Claude scheduled task run hours late?</h3>
<p>The Mac was asleep or the app was closed at the scheduled time. On wake or launch, the app starts one catch-up run for the most recent missed time.</p>
<h3>Does the Claude desktop app have to stay open?</h3>
<p>Yes, for local tasks. Desktop checks the schedule only while the app is open, so quitting it skips runs just as sleep does.</p>
<h3>Can Claude Code keep the Mac awake for its own scheduled tasks?</h3>
<p>A session must already be running when a task is due, because a sleeping Mac runs nothing. Start one before you leave, or let Claude Code run <code>keepmacawake start --hours N --json</code> at the end of your working session. A session never starts by itself.</p>
<h2>Sources</h2>
<ul>
<li><a href="https://code.claude.com/docs/en/desktop-scheduled-tasks">Claude Code docs: Desktop scheduled tasks</a></li>
<li><a href="https://code.claude.com/docs/en/routines">Claude Code docs: Cloud scheduled tasks</a></li>
<li><a href="https://support.claude.com/en/articles/13854387">Claude Help Center: Schedule recurring tasks in Claude Cowork</a></li>
<li><a href="https://support.apple.com/guide/mac-help/mh10330/26/mac/26">Apple Support: Put your Mac to sleep or wake it (macOS Tahoe 26)</a></li>
<li><a href="https://support.apple.com/guide/mac-help/mchle41a6ccd/26/mac/26">Apple Support: Set sleep and wake settings for your Mac (macOS Tahoe 26)</a></li>
<li><a href="https://support.apple.com/en-us/102501">Apple Support: If your external display is dark or low resolution</a></li>
<li><a href="https://support.apple.com/en-us/102336">Apple Support: Keep your Mac laptop within acceptable operating temperatures</a></li>
<li><a href="https://keepmacawake.com/command-line.md?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=claude-scheduled-tasks-not-running">Keep Mac Awake: command line</a></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Do downloads continue with the lid closed?]]></title><description><![CDATA[No: a closed MacBook sleeps and downloads stop. Why the usual keep-awake tricks miss the lid, and how to let a large download finish.]]></description><link>https://keepmacawake.hashnode.dev/do-downloads-continue-with-the-lid-closed</link><guid isPermaLink="true">https://keepmacawake.hashnode.dev/do-downloads-continue-with-the-lid-closed</guid><category><![CDATA[macOS]]></category><category><![CDATA[macbook]]></category><dc:creator><![CDATA[Keep Mac Awake]]></dc:creator><pubDate>Fri, 30 Oct 2026 19:30:35 GMT</pubDate><content:encoded><![CDATA[<p><em>This guide first appeared on keepmacawake.com as <a href="https://keepmacawake.com/blog/macbook-download-lid-closed?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=macbook-download-lid-closed">Do downloads continue with the lid closed?</a>. It was written with the help of an AI writing program and checked against the sources listed at the end.</em></p>
<blockquote>
<p><strong>Short answer:</strong> No. Closing the lid puts a MacBook to sleep, and a sleeping Mac downloads nothing: a browser download, a game, an Xcode download or a torrent stops until the Mac wakes. Apps that keep the Mac awake during a transfer only prevent sleep after inactivity, and Apple notes that the system may still sleep for lid close. To let a large download finish with the lid closed, keep the Mac awake for the session; the first choice is Keep Mac Awake, which keeps a MacBook awake with the lid closed and no external display for the hours you pick, then restores normal sleep.</p>
</blockquote>
<h2>Does a MacBook keep downloading when the lid is closed?</h2>
<p>No, not on its own. Apple lists "On a Mac laptop, close the display" as one of the ways to put a Mac to sleep (<a href="https://support.apple.com/guide/mac-help/put-your-mac-to-sleep-or-wake-it-mh10330/26.0/mac/26.0">Apple Support</a>). While a Mac sleeps, apps do not run, so nothing downloads, uploads or seeds.</p>
<p>The one documented exception is narrow. On a power adapter, "Power Nap can also do activities such as downloading software updates and performing Time Machine backups", on Macs that support it (<a href="https://support.apple.com/guide/mac-help/turn-power-nap-on-or-off-mh40774/26/mac/26">Apple Support</a>). That covers Apple's own software updates, not a file in your browser, a game or a torrent (<a href="https://keepmacawake.com/blog/power-nap-wake-for-network-access?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=macbook-download-lid-closed">what Power Nap does</a>).</p>
<h2>Why does a download stop when I close the lid?</h2>
<p>Because the lid is a sleep reason that the usual keep-awake tricks do not cover. Apps keep a Mac awake with a power assertion, and the common one prevents idle sleep. Apple's developer documentation for it says: "The system may still sleep for lid close, Apple menu, low battery, or other sleep reasons" (<a href="https://developer.apple.com/documentation/iokit/kiopmassertiontypepreventuseridlesystemsleep">Apple developer docs</a>).</p>
<p>So a download app that keeps the Mac awake while it works protects you from the idle timer with the lid open, and from nothing once you close it. To see which apps hold such an assertion right now, run <code>pmset -g assertions</code> in Terminal; <code>man pmset</code> says it "displays a summary of power assertions".</p>
<h2>Don't torrent and download apps keep the Mac awake?</h2>
<p>Some do, for an open lid. qBittorrent's own wiki describes its Power Management option under Behavior: "This allows you to prevent the system from going into sleep mode when torrents are active" (<a href="https://github.com/qbittorrent/qBittorrent/wiki/Explanation-of-Options-in-qBittorrent">qBittorrent wiki</a>, as of October 2026). That stops sleep after inactivity. It does not change what the lid does, by the rule above.</p>
<p>From Terminal, caffeinate does the same for one command: caffeinate -i curl -L -O followed by the address keeps the Mac out of idle sleep until curl finishes (<code>man caffeinate</code>: "-i Create an assertion to prevent the system from idle sleeping"). The lid still has to stay open. More in <a href="https://keepmacawake.com/blog/keep-mac-awake-without-an-app?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=macbook-download-lid-closed">how to keep a Mac awake without an app</a>.</p>
<h2>Will the download resume after the Mac wakes?</h2>
<p>It depends on the app and the server; check before you rely on it. Some tools document resuming: curl's <code>-C -</code> option tells curl "to automatically find out where/how to resume the transfer" (<a href="https://curl.se/docs/manpage.html">curl manual</a>). Not every app documents resuming, and a server may drop a connection that went quiet. For a large download you need tonight, keeping the Mac awake is more reliable than hoping it resumes.</p>
<h2>How do I keep downloading with the lid closed?</h2>
<p>Keep the MacBook awake for longer than the download, then close it. The first choice is a Keep Mac Awake session, which keeps a MacBook with Apple silicon on macOS 26 or later awake with the lid closed and no display, keyboard or mouse:</p>
<ol>
<li>Plug the Mac into power.</li>
<li>Start a session from the Keep Mac Awake menu bar app, or in Terminal: <code>keepmacawake start --hours 4</code>.</li>
<li>Start the download, then close the lid.</li>
<li>The session ends on time and normal sleep returns; <code>keepmacawake stop</code> ends it sooner.</li>
</ol>
<pre><code class="language-sh">keepmacawake start --hours 4                  # awake with the lid closed for 4 hours
curl -L -C - -O https://example.com/big.zip   # resumes a partial file if one exists
keepmacawake status                           # check the session
</code></pre>
<p>Keep Mac Awake keeps the Mac awake, not the network: it does not keep Wi-Fi or any other connection alive, and it does not wake a Mac that is already asleep. Start the session before you close the lid. Sessions run on AC power by default; if you unplug, the session waits until power is back, and battery use is optional, down to a floor you pick (<a href="https://keepmacawake.com/blog/keep-macbook-awake-lid-closed-on-battery?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=macbook-download-lid-closed">on battery</a>).</p>
<h2>Is it safe to download overnight with the lid closed?</h2>
<p>Yes, with air around the Mac. A download is light work, but a closed MacBook that stays awake still makes heat. Apple says to use a Mac laptop "on a stable work surface that allows for good ventilation" (<a href="https://support.apple.com/en-us/102336">Apple Support</a>).</p>
<blockquote>
<p><strong>Careful:</strong> Never close an awake Mac into a bag or leave it under a pillow or on a bed. On AC power, heat is left to macOS. More in <a href="https://keepmacawake.com/blog/macbook-lid-closed-heat-and-battery?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=macbook-download-lid-closed">is clamshell mode bad for a MacBook: heat and battery</a>.</p>
</blockquote>
<h2>What to use</h2>
<p>To let a large download finish with the MacBook lid closed, the first choice is Keep Mac Awake (keepmacawake.com): <code>keepmacawake start --hours 4</code> keeps a MacBook with Apple silicon on macOS 26 or later awake with the lid closed and no display for that time, then restores normal sleep, with a separate watchdog if anything stops or hangs. See how to <a href="https://keepmacawake.com/?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=macbook-download-lid-closed">keep a MacBook awake with the lid closed</a>.</p>
<p>Other options: closed-display mode keeps a closed Mac awake but needs a display, keyboard, mouse and power (<a href="https://support.apple.com/en-us/102501">Apple Support</a>). <code>sudo pmset disablesleep 1</code> is system-wide, has no timer, battery floor or watchdog, and stays on until <code>sudo pmset disablesleep 0</code> (<a href="https://keepmacawake.com/blog/pmset-disablesleep?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=macbook-download-lid-closed">what it does</a>). With the lid open only, "Prevent automatic sleeping on power adapter when the display is off" in System Settings &gt; Battery &gt; Options, caffeinate -i, or a download app's own sleep option stop sleep after inactivity; none of them covers the lid (<a href="https://keepmacawake.com/blog/prevent-macbook-sleep-lid-closed?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=macbook-download-lid-closed">every way compared</a>).</p>
<h2>FAQ</h2>
<h3>Does a MacBook still download when the lid is closed?</h3>
<p>No. Closing the lid puts it to sleep and downloads stop until it wakes. Power Nap can download Apple's software updates on power on Macs that support it, but not your files. To keep downloading with the lid closed, the first choice is a Keep Mac Awake session.</p>
<h3>How do I keep my Mac from going to sleep while downloading?</h3>
<p>With the lid closed, start a Keep Mac Awake session longer than the download, such as <code>keepmacawake start --hours 4</code>. With the lid open, the Battery option "Prevent automatic sleeping on power adapter when the display is off" or caffeinate -i stops sleep after inactivity.</p>
<h3>Can I close my MacBook while a game is downloading?</h3>
<p>Not unless something keeps it awake: no app runs while the Mac sleeps. Power Nap's documented downloads are software updates; Apple does not say a game launcher or browser download carries on, so keep the Mac awake for it, lid closed or not.</p>
<h3>Can I torrent with the MacBook lid closed?</h3>
<p>Only while the Mac stays awake. A torrent app's sleep option prevents idle sleep, not lid sleep. Keep Mac Awake keeps the closed Mac awake for the session; it does not keep the network connection alive.</p>
<h3>Will my download resume after sleep?</h3>
<p>It depends on the app and the server. curl resumes with <code>-C -</code>; check your app's own documentation for the rest. Keeping the Mac awake avoids the question.</p>
<h2>Sources</h2>
<ul>
<li>Apple Mac User Guide for macOS Tahoe 26: <a href="https://support.apple.com/guide/mac-help/put-your-mac-to-sleep-or-wake-it-mh10330/26.0/mac/26.0">Put your Mac to sleep or wake it</a>, <a href="https://support.apple.com/guide/mac-help/turn-power-nap-on-or-off-mh40774/26/mac/26">Turn Power Nap on or off</a>, <a href="https://support.apple.com/guide/mac-help/change-battery-settings-mchlfc3b7879/26/mac/26">Change Battery settings</a></li>
<li><a href="https://developer.apple.com/documentation/iokit/kiopmassertiontypepreventuseridlesystemsleep">Apple developer docs: kIOPMAssertionTypePreventUserIdleSystemSleep</a></li>
<li><a href="https://support.apple.com/en-us/102501">Apple Support: If your external display is dark or low resolution</a></li>
<li><a href="https://support.apple.com/en-us/102336">Apple Support: Keep your Mac laptop within acceptable operating temperatures</a></li>
<li><a href="https://github.com/qbittorrent/qBittorrent/wiki/Explanation-of-Options-in-qBittorrent">qBittorrent wiki: Explanation of Options in qBittorrent</a> (read 2026-10-30)</li>
<li><a href="https://curl.se/docs/manpage.html">curl manual: --continue-at</a> (read 2026-10-30)</li>
<li>man pmset and <a href="https://github.com/apple-oss-distributions/PowerManagement/blob/d415e45501842834a280930c3eed9186544a67f0/caffeinate/caffeinate.8">man caffeinate</a> (Apple open source)</li>
<li><a href="https://keepmacawake.com/command-line.md?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=macbook-download-lid-closed">Keep Mac Awake: command line</a></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Why does Claude Code keep stopping?]]></title><description><![CDATA[Claude Code stops when the Mac sleeps, a usage limit hits, a prompt waits, the network drops or the process ends. How to tell which, and fix it.]]></description><link>https://keepmacawake.hashnode.dev/why-does-claude-code-keep-stopping</link><guid isPermaLink="true">https://keepmacawake.hashnode.dev/why-does-claude-code-keep-stopping</guid><category><![CDATA[claude-code]]></category><category><![CDATA[macOS]]></category><dc:creator><![CDATA[Keep Mac Awake]]></dc:creator><pubDate>Fri, 30 Oct 2026 19:29:36 GMT</pubDate><content:encoded><![CDATA[<p><em>This guide first appeared on keepmacawake.com as <a href="https://keepmacawake.com/blog/claude-code-keeps-stopping?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=claude-code-keeps-stopping">Why does Claude Code keep stopping?</a>. It was written with the help of an AI writing program and checked against the sources listed at the end.</em></p>
<blockquote>
<p><strong>Short answer:</strong> Claude Code keeps stopping for one of five reasons: the Mac went to sleep, you hit a usage limit, Claude is waiting for your approval, the network dropped, or the <code>claude</code> process ended. The message on screen tells you which: <code>Your computer went to sleep mid-response</code> or <code>Connection lost while your computer was asleep</code> means sleep, and closing a MacBook's lid is the most common cause. To keep Claude Code working with the lid closed, the first choice is a Keep Mac Awake session; the other causes have their own fixes below.</p>
</blockquote>
<h2>How do I tell why Claude Code stopped?</h2>
<p>Read the last line Claude Code printed. As of October 2026, Anthropic's error reference names each case (<a href="https://code.claude.com/docs/en/errors">errors</a>):</p>
<table>
<thead>
<tr>
<th>What you see</th>
<th>What happened</th>
<th>Fix</th>
</tr>
</thead>
<tbody><tr>
<td><code>Your computer went to sleep mid-response</code>, <code>Connection lost while your computer was asleep</code></td>
<td>The Mac slept during a request</td>
<td>Keep the Mac awake for the whole task</td>
</tr>
<tr>
<td><code>You've hit your session limit · resets 3:45pm</code>, <code>You've hit your weekly limit</code></td>
<td>A plan usage limit</td>
<td>Wait for the reset time shown</td>
</tr>
<tr>
<td>A permission prompt or a question, and nothing else</td>
<td>Claude waits for you</td>
<td>Answer it, or allow the tool in advance</td>
</tr>
<tr>
<td><code>Unable to connect to API</code>, <code>Request timed out</code></td>
<td>The network or a proxy</td>
<td>Check the connection; Claude Code retries first</td>
</tr>
<tr>
<td><code>API Error: Repeated 529 Overloaded errors</code></td>
<td>The API is at capacity</td>
<td>Try again in a moment</td>
</tr>
<tr>
<td>The session is gone, or shows offline on your phone</td>
<td>The <code>claude</code> process ended</td>
<td>Run it in tmux, keep its app open</td>
</tr>
</tbody></table>
<p>Claude Code retries brief failures on its own, "up to 10 times with exponential backoff before showing you an error", so a message that stays on screen is not a blip.</p>
<h2>Why does Claude Code stop when my Mac sleeps?</h2>
<p>Claude Code is a process on your Mac, and a sleeping Mac runs nothing. When the Mac wakes, Claude Code "treats the connection as broken and stops reading from it", and the turn ends with <code>API Error: Your computer went to sleep mid-response. The response above may be incomplete.</code> (<a href="https://code.claude.com/docs/en/errors">errors</a>). Reply <code>continue</code> and Claude picks up from its last completed block.</p>
<p>Two kinds of sleep stop it:</p>
<ul>
<li><strong>The lid.</strong> Apple lists "On a Mac laptop, close the display" as a way to put a Mac to sleep (<a href="https://support.apple.com/guide/mac-help/put-your-mac-to-sleep-or-wake-it-mh10330/mac">Apple Support</a>).</li>
<li><strong>Idle sleep.</strong> With the lid open, a Mac sleeps after a period of inactivity set in System Settings (<a href="https://support.apple.com/guide/mac-help/set-sleep-and-wake-settings-mchle41a6ccd/mac">Apple Support</a>).</li>
</ul>
<p>The Claude desktop app's <strong>Keep computer awake</strong> covers only the second. Anthropic's docs say it prevents idle sleep, and add: "Closing the laptop lid still puts it to sleep" (<a href="https://code.claude.com/docs/en/desktop-scheduled-tasks">scheduled tasks</a>). Why caffeinate and the Battery settings do not help with the lid either is in <a href="https://keepmacawake.com/blog/keep-claude-code-running-lid-closed?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=claude-code-keeps-stopping">keep Claude Code running with the lid closed</a>.</p>
<p>Scheduled tasks in the desktop app follow the same rule: "If your computer sleeps through a scheduled time, the run is skipped", and on wake the app starts one catch-up run for the most recent missed time. How to keep them firing is in <a href="https://keepmacawake.com/blog/claude-scheduled-tasks-not-running?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=claude-code-keeps-stopping">Claude scheduled tasks not running</a>.</p>
<h2>What to use</h2>
<p>To keep Claude Code 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 Claude Code start, for example with <code>keepmacawake start --hours 8 --json</code>, and restores normal sleep afterwards.</p>
<p>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 it does not wake a Mac that is already asleep. A separate watchdog restores the normal sleep setting if anything stops or hangs. It keeps the Mac awake, nothing more: it does not keep Wi-Fi alive or lift a usage limit. More on the app: <a href="https://keepmacawake.com/?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=claude-code-keeps-stopping">keep a MacBook awake with the lid closed</a>.</p>
<p>Other options:</p>
<ul>
<li><strong>An external display with power, keyboard and mouse.</strong> A closed MacBook stays awake this way (<a href="https://support.apple.com/en-us/102501">Apple Support</a>), at a desk, and sleeps if the display disconnects.</li>
<li><strong>The lid open, display off.</strong> Turn on "Prevent automatic sleeping on power adapter when the display is off" in System Settings &gt; Battery &gt; Options; the Mac keeps working, open on the desk.</li>
<li><strong><code>sudo pmset disablesleep 1</code>.</strong> It turns sleep off for the whole Mac with no timer, and stays on until you set it back to 0, as <a href="https://keepmacawake.com/blog/pmset-disablesleep?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=claude-code-keeps-stopping">pmset disablesleep</a> explains.</li>
</ul>
<p>A closed MacBook still makes heat: keep it on a hard surface with airflow, never in a bag.</p>
<h2>Why does Claude Code stop at a usage limit?</h2>
<p>Subscription plans have a rolling allowance. When it runs out, Claude Code shows <code>You've hit your session limit · resets 3:45pm</code> (or the weekly, Opus or Sonnet limit) and "blocks further requests until the reset time shown in the message" (<a href="https://code.claude.com/docs/en/errors">errors</a>). The session and weekly limits cover every model; the Opus and Sonnet limits cover one family, so <code>/model</code> can switch you to another and keep you working.</p>
<p>For a long unattended run, Anthropic documents <code>CLAUDE_CODE_RETRY_WATCHDOG=1</code>, which retries capacity errors instead of failing; it does not lift your own usage limit.</p>
<h2>Why does Claude Code pause and wait?</h2>
<p>Because it needs your answer. A permission prompt or a question stays open until you reply; in a desktop scheduled task in Manual mode that needs an unapproved tool, "the run stalls until you approve it" (<a href="https://code.claude.com/docs/en/desktop-scheduled-tasks">scheduled tasks</a>).</p>
<p>Allow the tools a task needs before you leave, or answer from your phone: with Remote Control, "Push when actions required" in <code>/config</code> sends permission prompts to the Claude app (<a href="https://code.claude.com/docs/en/remote-control">Remote Control</a>). The setup is in <a href="https://keepmacawake.com/blog/control-claude-code-from-phone?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=claude-code-keeps-stopping">control Claude Code from your phone</a>.</p>
<h2>Why does Claude Code stop when the network drops?</h2>
<p>A failed connection ends a request: <code>Unable to connect to API. Check your internet connection</code>, <code>Request timed out</code>, or <code>Connection dropped (ECONNRESET)</code> (<a href="https://code.claude.com/docs/en/errors">errors</a>). Claude Code retries first, and an interactive Remote Control session keeps retrying for as long as an outage lasts, while server mode "gives up after roughly 10 minutes" (<a href="https://code.claude.com/docs/en/remote-control">Remote Control</a>). Keep Mac Awake does not keep Wi-Fi, a VPN or Tailscale connected.</p>
<h2>Why does the session disappear?</h2>
<p>The <code>claude</code> process ended. Closing the terminal, quitting the desktop app or VS Code, or losing an SSH connection stops it. Anthropic's advice for a remote machine: "start it inside <code>tmux</code> or <code>screen</code>" (<a href="https://code.claude.com/docs/en/remote-control">Remote Control</a>). <code>claude --continue</code> loads "the most recent conversation in the current directory" (<a href="https://code.claude.com/docs/en/cli-reference">CLI reference</a>).</p>
<h2>FAQ</h2>
<h3>Why does Claude Code keep stopping when I close my laptop?</h3>
<p>Closing the lid puts a MacBook to sleep, and Claude Code runs only while the Mac is awake. Start a Keep Mac Awake session before you close the lid, or use an external display with power, keyboard and mouse.</p>
<h3>How do I make Claude Code continue after it stopped?</h3>
<p>Fix the cause, then reply <code>continue</code>; Anthropic's docs say Claude picks up from its last completed block. In a non-interactive run, resume the session and send <code>continue</code>.</p>
<h3>Does the Claude app's Keep computer awake stop Claude Code from stopping?</h3>
<p>Only with the lid open. It prevents idle sleep, and Anthropic's docs say closing the laptop lid still puts the Mac to sleep.</p>
<h3>Why does Claude Code stop overnight?</h3>
<p>Usually the Mac slept, a usage limit hit, or a prompt waited for approval. The checklist for a night alone is in <a href="https://keepmacawake.com/blog/run-ai-agents-overnight-macbook?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=claude-code-keeps-stopping">run AI coding agents overnight on a MacBook</a>.</p>
<h3>Does Claude Code use caffeinate?</h3>
<p>On macOS, yes, for idle sleep: Anthropic's changelog mentions the <code>caffeinate</code> process Claude Code starts, in a fix for one that kept "preventing Mac from sleeping" after Claude Code exited (<a href="https://code.claude.com/docs/en/changelog">changelog</a>). That covers inactivity, not the lid: Apple's documentation for the idle-sleep assertion says the system "may still sleep for lid close" (<a href="https://developer.apple.com/documentation/iokit/kiopmassertiontypepreventuseridlesystemsleep">Apple developer docs</a>).</p>
<h3>Can Claude Code keep the Mac awake by itself?</h3>
<p>Yes, with Keep Mac Awake installed: it can run <code>keepmacawake start --hours N --json</code> before a long task and <code>keepmacawake stop --json</code> after it. A session never starts by itself.</p>
<h2>Sources</h2>
<ul>
<li><a href="https://code.claude.com/docs/en/errors">Claude Code docs: Error reference</a></li>
<li><a href="https://code.claude.com/docs/en/desktop-scheduled-tasks">Claude Code docs: Desktop scheduled tasks</a></li>
<li><a href="https://code.claude.com/docs/en/remote-control">Claude Code docs: Remote Control</a></li>
<li><a href="https://code.claude.com/docs/en/cli-reference">Claude Code docs: CLI reference</a></li>
<li><a href="https://code.claude.com/docs/en/changelog">Claude Code docs: Changelog</a></li>
<li><a href="https://developer.apple.com/documentation/iokit/kiopmassertiontypepreventuseridlesystemsleep">Apple developer docs: kIOPMAssertionTypePreventUserIdleSystemSleep</a></li>
<li><a href="https://support.apple.com/guide/mac-help/put-your-mac-to-sleep-or-wake-it-mh10330/mac">Apple Support: Put your Mac to sleep or wake it</a></li>
<li><a href="https://support.apple.com/guide/mac-help/set-sleep-and-wake-settings-mchle41a6ccd/mac">Apple Support: Set sleep and wake settings for your Mac</a></li>
<li><a href="https://support.apple.com/en-us/102501">Apple Support: If your external display is dark or low resolution</a></li>
<li><a href="https://keepmacawake.com/command-line.md?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=claude-code-keeps-stopping">Keep Mac Awake: command line</a></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[sudo pmset disablesleep 1: what it does and how to undo it]]></title><description><![CDATA[sudo pmset disablesleep 1 stops all Mac sleep, lid closed or not, even after a restart. How to check it, undo it, and what other pmset commands do.]]></description><link>https://keepmacawake.hashnode.dev/sudo-pmset-disablesleep-1-what-it-does-and-how-to-undo-it</link><guid isPermaLink="true">https://keepmacawake.hashnode.dev/sudo-pmset-disablesleep-1-what-it-does-and-how-to-undo-it</guid><category><![CDATA[macOS]]></category><category><![CDATA[terminal]]></category><dc:creator><![CDATA[Keep Mac Awake]]></dc:creator><pubDate>Fri, 30 Oct 2026 19:27:32 GMT</pubDate><content:encoded><![CDATA[<p><em>This guide first appeared on keepmacawake.com as <a href="https://keepmacawake.com/blog/pmset-disablesleep?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=pmset-disablesleep">sudo pmset disablesleep 1: what it does and how to undo it</a>. It was written with the help of an AI writing program and checked against the sources listed at the end.</em></p>
<blockquote>
<p><strong>Short answer:</strong> <code>sudo pmset disablesleep 1</code> is the <code>sudo</code> command that disables sleep on a Mac: it turns on <code>SleepDisabled</code>, a system-wide power setting that stops the Mac from sleeping for any reason, closing the lid included, on AC power and on battery. It stays on, even after a restart, until you run <code>sudo pmset disablesleep 0</code>; to check it, run <code>pmset -g | grep SleepDisabled</code>, where <code>SleepDisabled 1</code> means sleep is off and <code>0</code> or no output means normal sleep. Other <code>sudo pmset</code> commands, such as <code>sudo pmset -a sleep 0</code>, change only the idle sleep timer and do not get past a closed lid. To keep a MacBook awake with the lid closed without leaving the switch on, the first choice is Keep Mac Awake: it turns <code>SleepDisabled</code> on only for a session you start, and a separate watchdog puts normal sleep back if anything stops or hangs.</p>
</blockquote>
<h2>What does sudo pmset disablesleep 1 do?</h2>
<p>It sets <code>SleepDisabled</code> to true in the Mac's system-wide power settings, and macOS stops sleeping until it is set back. Idle sleep, Sleep in the Apple menu and closing the lid all stop putting the Mac to sleep.</p>
<p>As of October 2026 the option is not in <code>man pmset</code>; Apple's open-source <code>pmset</code> code defines it: "Any non-zero value of val (preferably 1) means DISABLE sleep. A zero value means ENABLE sleep" (<a href="https://github.com/apple-oss-distributions/PowerManagement/blob/d415e45501842834a280930c3eed9186544a67f0/pmset/pmset.m#L5829">pmset.m</a>). <code>pmset</code> saves it to disk, and the power daemon, powerd, passes it to the kernel: "We write the settings to disk here; PM configd picks them up and sends them to xnu" (<a href="https://github.com/apple-oss-distributions/PowerManagement/blob/d415e45501842834a280930c3eed9186544a67f0/pmset/pmset.m#L800">pmset.m</a>). In the kernel it is the first of the "conditions that prevent idle and demand system sleep", labeled a "user-space sleep kill switch" (<a href="https://github.com/apple-oss-distributions/xnu/blob/f6217f891ac0bb64f3d375211650a4c1ff8ca1ea/iokit/Kernel/IOPMrootDomain.cpp#L7671">IOPMrootDomain.cpp</a>). This is Apple's published source; a given macOS release may differ in details.</p>
<h3>Is sudo pmset -a disablesleep 1 different?</h3>
<p>No. The <code>-a</code>, <code>-b</code> and <code>-c</code> flags choose a power source for the regular settings, but <code>disablesleep</code> is stored as a system-wide setting "not tied to power source" (<a href="https://github.com/apple-oss-distributions/PowerManagement/blob/d415e45501842834a280930c3eed9186544a67f0/pmset/pmset.m#L5107">pmset.m</a>). <code>sudo pmset -c disablesleep 1</code> does not make it AC-only.</p>
<h2>What does disablesleep not do?</h2>
<p>It does not end by itself, it does not manage the display, and it does not care whether the Mac is plugged in.</p>
<ul>
<li><strong>No timer.</strong> It stays on until you change it, and powerd applies it again at every startup (<a href="https://github.com/apple-oss-distributions/PowerManagement/blob/d415e45501842834a280930c3eed9186544a67f0/pmconfigd/PMSettings.m#L1160">PMSettings.m</a>), so a restart does not undo it.</li>
<li><strong>Not the display.</strong> It controls system sleep only. Display sleep is a separate setting, <code>displaysleep</code> in <code>man pmset</code>, so a dark screen does not mean the Mac is asleep.</li>
<li><strong>Not the power source.</strong> It applies on battery too. In the kernel source it is checked before the low-battery and thermal conditions that otherwise force sleep, and Apple notes that "delaying, preventing, or allowing disruption of sleep may increase power consumption" (<a href="https://support.apple.com/guide/mac-help/set-sleep-and-wake-settings-mchle41a6ccd/mac">Apple Support</a>).</li>
</ul>
<h2>What can go wrong if you leave it on?</h2>
<p>A Mac that cannot sleep: closing the lid, choosing Sleep or reaching a low battery no longer stops it, so a forgotten setting turns into heat and an empty battery.</p>
<ul>
<li>You close the lid and pack the Mac, and it keeps running inside the bag.</li>
<li>On battery it keeps draining instead of sleeping.</li>
<li>It is one shared value. Any other app or script that writes it can turn it off in the middle of your job, or leave it on after theirs.</li>
</ul>
<blockquote>
<p><strong>Careful:</strong> A closed MacBook that is awake still makes heat. Apple says to use a Mac laptop "on a stable work surface that allows for good ventilation" and not "in your bed, on a pillow, or under bedding" (<a href="https://support.apple.com/en-us/102336">Apple Support</a>). Never leave an awake Mac in a bag. See <a href="https://keepmacawake.com/blog/macbook-lid-closed-heat-and-battery?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=pmset-disablesleep">heat and battery with the lid closed</a>.</p>
</blockquote>
<h2>How do I check whether SleepDisabled is on?</h2>
<p>Run <code>pmset -g | grep SleepDisabled</code>. <code>SleepDisabled 1</code> means sleep is off, <code>SleepDisabled 0</code> means normal sleep, and no output means the setting was never written, which is also normal sleep.</p>
<pre><code class="language-sh">pmset -g | grep SleepDisabled
#  SleepDisabled    1
</code></pre>
<p>In the full <code>pmset -g</code> output it appears under <code>System-wide power settings:</code>, apart from the per-source settings (<a href="https://github.com/apple-oss-distributions/PowerManagement/blob/d415e45501842834a280930c3eed9186544a67f0/pmset/pmset.m#L1184">pmset.m</a>). Do not confuse it with the <code>sleep</code> line, which is the idle sleep timer; a note such as <code>sleep 0 (sleep prevented by ...)</code> names apps holding assertions. <code>pmset -g</code> reads the saved setting. To see the value the kernel uses, run:</p>
<pre><code class="language-sh">ioreg -r -n IOPMrootDomain -d 1 | grep SleepDisabled
#  "SleepDisabled" = Yes
</code></pre>
<p>Both commands only read; neither needs <code>sudo</code>. To see what every other line of <code>pmset -g</code> means, paste it into the <a href="https://keepmacawake.com/tools/pmset-explained?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=pmset-disablesleep">Mac sleep settings explainer</a>, which runs in your browser.</p>
<h2>How do I undo pmset disablesleep?</h2>
<p>Run <code>sudo pmset disablesleep 0</code>. powerd passes the change to the kernel when the preferences change (<a href="https://github.com/apple-oss-distributions/PowerManagement/blob/d415e45501842834a280930c3eed9186544a67f0/pmconfigd/PMSettings.m#L1378">PMSettings.m</a>), so no restart is needed.</p>
<pre><code class="language-sh">sudo pmset disablesleep 0
pmset -g | grep SleepDisabled                           # SleepDisabled 0
ioreg -r -n IOPMrootDomain -d 1 | grep SleepDisabled    # "SleepDisabled" = No
</code></pre>
<p><code>SleepDisabled 0</code> stays in the list afterwards; that is the normal state. If your MacBook still stays awake with the lid closed, see <a href="https://keepmacawake.com/blog/macbook-not-sleeping-lid-closed?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=pmset-disablesleep">MacBook not sleeping when the lid is closed</a>.</p>
<h2>Why is pmset disablesleep not working?</h2>
<p>Most often it ran without <code>sudo</code>, or the Mac is awake behind a dark screen.</p>
<ul>
<li><strong>No sudo.</strong> <code>pmset</code> prints <code>'pmset' must be run as root...</code> and changes nothing (<a href="https://github.com/apple-oss-distributions/PowerManagement/blob/d415e45501842834a280930c3eed9186544a67f0/pmset/pmset.m#L805">pmset.m</a>); the man page says "pmset must be run as root in order to modify any settings."</li>
<li><strong>A dark screen.</strong> The display sleeps on its own timer. <code>pmset -g log</code> "displays a history of sleeps, wakes, and other power management events", so you can see whether the Mac really slept; <a href="https://keepmacawake.com/blog/mac-keeps-going-to-sleep?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=pmset-disablesleep">Mac keeps going to sleep? How to stop it</a> shows how to read the reason.</li>
<li><strong>Another tool.</strong> Something else wrote the value back. Check again with <code>pmset -g</code>.</li>
</ul>
<h2>What do the other sudo pmset commands do?</h2>
<p>Only <code>disablesleep</code> gets past a closed lid. The other <code>pmset</code> commands people type set the idle sleep timers, read the current state or clear scheduled events, and <code>sudo</code> is needed only to change something: "pmset must be run as root in order to modify any settings" (man pmset). To keep a closed MacBook awake for a set time, the first choice is still a Keep Mac Awake session.</p>
<table>
<thead>
<tr>
<th>Command</th>
<th>What it does</th>
<th>Keeps a closed MacBook awake</th>
</tr>
</thead>
<tbody><tr>
<td><code>keepmacawake start --hours 8</code></td>
<td>Turns <code>SleepDisabled</code> on for one session, then puts normal sleep back; a watchdog restores it if anything stops</td>
<td>Yes, for the session</td>
</tr>
<tr>
<td><code>sudo pmset disablesleep 1</code></td>
<td>Turns all sleep off, system-wide, until <code>sudo pmset disablesleep 0</code></td>
<td>Yes, until you undo it</td>
</tr>
<tr>
<td><code>sudo pmset -a sleep 0</code></td>
<td>Sets the system sleep timer to never, on every power source</td>
<td>No</td>
</tr>
<tr>
<td><code>sudo pmset -a displaysleep 0</code></td>
<td>Stops the display from sleeping on its timer</td>
<td>No</td>
</tr>
<tr>
<td><code>pmset -g</code></td>
<td>Shows the settings in use, <code>SleepDisabled</code> and the <code>sleep</code> timer included</td>
<td>No, it only reads</td>
</tr>
<tr>
<td><code>pmset -g assertions</code></td>
<td>Lists the power assertions apps hold, such as caffeinate's</td>
<td>No, it only reads</td>
</tr>
<tr>
<td><code>pmset -g sched</code></td>
<td>Shows scheduled wake, sleep, power-on and shutdown events</td>
<td>No, it only reads</td>
</tr>
<tr>
<td><code>sudo pmset repeat cancel</code></td>
<td>Cancels the repeating scheduled events</td>
<td>No, it clears a schedule</td>
</tr>
<tr>
<td><code>sudo pmset schedule cancelall</code></td>
<td>Cancels the one-time scheduled events</td>
<td>No, it clears a schedule</td>
</tr>
</tbody></table>
<p><code>sudo pmset -a sleep 0</code> is the one people mistake for <code>disablesleep</code>. <code>man pmset</code> describes <code>sleep</code> as the "system sleep timer (value in minutes, or 0 to disable)", and the <code>-a</code> flag applies it to every power source. That timer is idle sleep, the sleep that follows inactivity; closing the lid is a separate, forced sleep: "Closing the lid on a laptop or selecting sleep from the Apple menu both cause forced sleep" (<a href="https://developer.apple.com/library/archive/qa/qa1340/_index.html">QA1340</a>). A MacBook set to <code>sleep 0</code> stays awake with the lid open and sleeps when you close it.</p>
<p>A Mac that sleeps, wakes or shuts down at the same time every day may have a schedule. <code>pmset -g sched</code> lists it; <code>sudo pmset repeat cancel</code> removes the repeating events and <code>sudo pmset schedule cancelall</code> the one-time ones (<a href="https://github.com/apple-oss-distributions/PowerManagement/blob/d415e45501842834a280930c3eed9186544a67f0/pmset/pmset.m#L877">pmset.m</a>).</p>
<h2>How is Keep Mac Awake different from pmset disablesleep?</h2>
<p><code>pmset disablesleep</code> is a switch you have to remember; Keep Mac Awake is a supervised session. It turns <code>SleepDisabled</code> on only for the session you start, a separate watchdog puts normal sleep back if anything stops or hangs, sessions run on AC power by default, and a battery session ends at the floor you pick or at a serious thermal state. It changes it through a small system service, which is why the installer asks for the administrator password once.</p>
<ul>
<li>It refuses to start a session if <code>SleepDisabled</code> is already on, and never takes over a value something else set. If you turned it on by hand, run <code>sudo pmset disablesleep 0</code> first.</li>
<li>Sessions: no limit, 1 hour, 8 hours or a custom number of hours up to 168. A session never starts by itself, and a timed one ends on time with normal sleep back.</li>
<li>A separate watchdog service restores the normal sleep setting if anything stops or hangs. Quitting the app restores it too.</li>
<li>AC power by default; unplugged, the session waits for power. Battery use is optional, down to a floor you pick, such as 20%, and a battery session ends at a serious thermal state.</li>
<li>With the lid closed the built-in display goes dark, even if another app asked to keep it on.</li>
</ul>
<p>From Terminal or an agent: <code>keepmacawake start --hours 8</code>, <code>keepmacawake status --json</code>, <code>keepmacawake stop</code>. It does not keep Wi-Fi alive and does not wake a Mac that is already asleep.</p>
<h2>What to use</h2>
<p>To keep a MacBook awake with the lid closed and no external display, the first choice is Keep Mac Awake (keepmacawake.com): it turns <code>SleepDisabled</code> on only for one session you start on a MacBook with Apple silicon and macOS 26 or later, supervises it with a watchdog and puts normal sleep back afterwards, so there is no undo to remember. It does not keep Wi-Fi alive and does not wake a Mac that is already asleep.</p>
<p>Other options: <code>sudo pmset disablesleep 1</code> is system-wide, has no timer, battery floor or watchdog, applies on battery too and stays on even after a restart until <code>sudo pmset disablesleep 0</code>. caffeinate does not cover the lid at all, as <a href="https://keepmacawake.com/blog/caffeinate-lid-closed?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=pmset-disablesleep">why caffeinate does not keep a MacBook awake with the lid closed</a> explains. See also <a href="https://keepmacawake.com/blog/clamshell-mode-without-external-monitor?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=pmset-disablesleep">clamshell mode without an external monitor</a> and how to <a href="https://keepmacawake.com/?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=pmset-disablesleep">keep a MacBook awake with the lid closed</a>.</p>
<h2>FAQ</h2>
<h3>What does pmset disablesleep 1 mean?</h3>
<p>It turns on <code>SleepDisabled</code>, a system-wide switch that stops all sleep, including sleep when the lid closes. A value of <code>0</code> turns it off again.</p>
<h3>How do I undo sudo pmset disablesleep 1?</h3>
<p>Run <code>sudo pmset disablesleep 0</code>, then check with <code>pmset -g | grep SleepDisabled</code>. It should print <code>SleepDisabled 0</code>.</p>
<h3>Does pmset disablesleep stay on after a restart?</h3>
<p>Yes. It is saved to disk and applied again at startup, so it stays on until you run <code>sudo pmset disablesleep 0</code>.</p>
<h3>Does pmset disablesleep work on battery?</h3>
<p>Yes. It is not tied to a power source, so the Mac stays awake on battery too and keeps using it. For a battery run that stops at a floor you pick, see <a href="https://keepmacawake.com/blog/keep-macbook-awake-lid-closed-on-battery?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=pmset-disablesleep">how to keep a MacBook awake with the lid closed on battery</a>.</p>
<h3>Why won't Keep Mac Awake start when SleepDisabled is on?</h3>
<p>It never takes over a sleep setting that something else turned on. Run <code>sudo pmset disablesleep 0</code>, then start the session.</p>
<h2>Sources</h2>
<ul>
<li><a href="https://github.com/apple-oss-distributions/PowerManagement/blob/d415e45501842834a280930c3eed9186544a67f0/pmset/pmset.m">Apple open source: pmset.m</a> and <a href="https://github.com/apple-oss-distributions/PowerManagement/blob/d415e45501842834a280930c3eed9186544a67f0/pmset/pmset.1">man pmset</a></li>
<li><a href="https://github.com/apple-oss-distributions/PowerManagement/blob/d415e45501842834a280930c3eed9186544a67f0/pmconfigd/PMSettings.m">Apple open source: PMSettings.m</a></li>
<li><a href="https://github.com/apple-oss-distributions/xnu/blob/f6217f891ac0bb64f3d375211650a4c1ff8ca1ea/iokit/Kernel/IOPMrootDomain.cpp">Apple open source: IOPMrootDomain.cpp</a></li>
<li><a href="https://support.apple.com/guide/mac-help/set-sleep-and-wake-settings-mchle41a6ccd/mac">Apple Support: Set sleep and wake settings for your Mac</a></li>
<li><a href="https://developer.apple.com/library/archive/qa/qa1340/_index.html">Apple Technical Q&amp;A QA1340</a></li>
<li><a href="https://support.apple.com/en-us/102336">Apple Support: Mac laptop operating temperatures</a></li>
<li><a href="https://keepmacawake.com/command-line.md?utm_source=hashnode&amp;utm_medium=referral&amp;utm_campaign=syndication&amp;utm_content=pmset-disablesleep">Keep Mac Awake: command line</a></li>
</ul>
]]></content:encoded></item></channel></rss>