Why your agent sessions die overnight, and how to fix it
You left a machine on so your agents could work while you sleep. In the morning, the session is gone. It’s almost always one of five things.
Published
People set up an always-on machine, whether a Windows desktop, a Mac mini or a small VPS, then drive their agents remotely: from a phone, a laptop, or a remote-control feature in the agent itself. It works in the evening and is dead by morning. Here’s where to look.
1. The machine went to sleep anyway
Power settings often win over good intentions.
- Windows: set sleep to Never on AC power with
powercfg /change standby-timeout-ac 0, and check that hibernation and “hybrid sleep” are off if you don’t need them. - macOS: turn on Prevent automatic sleeping when the display is off in System Settings → Displays → Advanced (or Energy), or run
caffeinate -swhile on power. - Linux laptop: make sure closing the lid doesn’t suspend (
HandleLidSwitch=ignorein/etc/systemd/logind.conf).
2. The network adapter powered down
Some network adapters save power when idle, even when the computer is awake. On Windows, open Device Manager → your adapter → Power Management and untick Allow the computer to turn off this device to save power. Wi-Fi is less reliable than Ethernet for an always-on box.
3. The process was killed for memory
Agents run installs, builds and test suites, which can use a lot of memory. When memory runs out, the operating system kills a process, sometimes your agent. On Linux, check dmesg for “Out of memory”. On small VPS instances this is the most common cause.
4. An update restarted the machine
Automatic OS updates restart overnight by design. Schedule update restarts for a time you choose, and run agents inside tmux or a service so they can be restarted easily.
5. The session wasn’t detached from your connection
If the agent was started from an SSH session or a terminal window, it can end when that connection drops. Run it inside tmux so it outlives the connection, and reattach in the morning.
Or skip the machine maintenance
Everything above is the price of running your own always-on box. Cube is a Linux computer in the cloud that’s built to stay on: your agents keep running, you check in from your phone or your Mac, and there are no power settings to fight.
Questions
Why does my Claude Code session disconnect when my computer sleeps?
A sleeping computer drops its network connection and pauses every process. Remote sessions can’t reach a sleeping machine, and some won’t reconnect on their own when it wakes.
How do I stop Windows from sleeping for an always-on agent box?
Set sleep to Never on power (powercfg /change standby-timeout-ac 0), turn off hibernation if you don’t need it, and check the network adapter isn’t allowed to power down.
Is there a way to avoid this entirely?
Run your agents on a computer that’s built to stay on and reachable, like a server or a managed cloud computer such as Cube.