---
title: "Discussion on \"Claude Code stops when your Mac sleeps: the quick fixes\" | Hashnode"
description: "Discussion on \"Claude Code stops when your Mac sleeps: the quick fixes\". Your Mac went to sleep and Claude Code froze. Fix it with caffeinate and pmset, in the order to try them, with copyable commands."
url: "https://hashnode.com/posts/claude-code-stops-when-your-mac-sleeps-the-quick-fixes/6adf50ad92cceff05c10caed"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Claude Code stops when your Mac sleeps: the quick fixes](https://macrun.hashnode.dev/claude-code-stops-when-your-mac-sleeps-the-quick-fixes?utm_source=hashnode&utm_medium=feed)

Your Mac went to sleep and Claude Code froze. Fix it with caffeinate and pmset, in the order to try them, with copyable commands.

Oct 26 · 3 min read · macrun.hashnode.dev  
Read the article

-   [#developer-tools](https://hashnode.com/tag/developer-tools)
-   [#macos](https://hashnode.com/tag/macos)
-   [#AI](https://hashnode.com/tag/AI)
-   [#productivity](https://hashnode.com/tag/productivity)

## Written by

[MacRun](https://hashnode.com/@macrun)

@macrun · New Jersey, USA

  
[View profile](https://hashnode.com/@macrun)

Dedicated M6 Mac minis for iOS builds, CI and AI coding agents.

MacRun rents dedicated M6 Mac minis by the day, week or month. Each Mac belongs to one customer. People use them to build and ship iOS apps from Windows or Linux, as CI runners, and as always-on Macs for Claude Code and Codex. Guides here are from macrun.dev.

## Responses 2

Markdown supported · ⌘↵ to post

[Mateo Ruiz](https://hashnode.com/@mateoruiz)

[Oct 30](https://hashnode.com/posts/claude-code-stops-when-your-mac-sleeps-the-quick-fixes/6adf50ad92cceff05c10caed/comment/6ae4a07a41190ba61d30fbfb)

One thing worth adding is that keeping the machine awake solves only the infrastructure side of the problem. It doesn’t guarantee the agent task survives a dropped API connection, terminal crash, or unexpected reboot.

For longer coding tasks, I’d treat `caffeinate` and `tmux` as convenience measures, but make the workflow resumable as well: persist task state, keep important outputs in files or commits, and make tool operations safe to retry. That way, even if the Mac does sleep, the work doesn’t have to start from zero. An always-on machine improves availability; recoverability is what makes the setup reliable.

[MacRun](https://hashnode.com/@macrun)

[Oct 30](https://hashnode.com/posts/claude-code-stops-when-your-mac-sleeps-the-quick-fixes/6adf50ad92cceff05c10caed/comment/6ae4a07a41190ba61d30fbfb#reply-6ae4b42ca536be2ed7cf9222)

Good point, and I agree. Staying awake only keeps the Mac alive. It does not save the work.

A few things that help with Claude Code in particular:

-   `claude --continue` picks up the last session in that folder, and `claude --resume` lets you choose an older one. A crashed terminal does not have to end the task.
-   Ask the agent to commit after each working step, on its own branch. A bad reboot then costs one step, not the whole run.
-   Keep a short progress file in the repo with what is done and what is next. After a restart, the agent reads it and carries on.
-   On a Mac that runs unattended, set `sudo pmset -a autorestart 1` so it comes back on by itself after a power cut.

Thanks for adding this. Recoverability is the part most setups skip.
