Short answer: on a laptop, an unattended Claude Code session lasts until the first of these happens: the laptop sleeps, the network is gone for too long, the claude process stops, or the login can't be renewed. With normal power settings, sleep almost always comes first, so the honest answer is "until your sleep timer fires", which can be minutes after you walk away. On a machine that never sleeps, the session runs far longer, and what's left are logins, restarts and drops on the server side.
How this page was put together
This is not a benchmark, and there is no stopwatch data here. Every time on this page comes from Anthropic's Claude Code docs or from public bug reports, linked inline, and each row says which one it is. Your own numbers depend on your OS, your power settings, your network and your Claude Code version. At the end there's a small script to measure your own machine.
The timeline, shortest first
| When | What ends or pauses the session | Source |
|---|---|---|
| When your sleep timer fires, or right away on lid close | The OS freezes the claude process. Nothing runs until the laptop wakes | Your power settings |
| Up to 3 minutes | After a VPN or network change, if something answers with HTTP 403, Claude Code retries for up to three minutes, then disconnects Remote Control | Remote Control docs |
| About 10 minutes | Laptop awake, network down: server mode (claude remote-control) gives up after roughly 10 minutes and exits. An interactive session keeps retrying | Remote Control docs |
| About 20 minutes idle | People report idle Remote Control sessions dropping server-side, with the computer awake | User reports in #32982 |
| About 30 minutes | An interactive session whose heartbeats keep failing disconnects with "could not reach the Remote Control server for about 30 minutes" | Remote Control docs |
| About an hour | A background session (claude --bg) that is finished or waiting for you, and not attached, has its process stopped to free resources, unless you pin it | Agent view docs |
| About 4 hours | After server mode stops, claude remote-control --continue in the same folder brings its sessions back only within about four hours | Remote Control docs |
| 1 to 2 days, in one setup | A headless server lost its login every 1 to 2 days when many Claude Code processes shared one credentials file | User report in #102985 |
| When the saved login expires | Requests fail with "Login expired". Claude Code warns three days ahead, but only at startup | Authentication docs |
| 7 days | Recurring tasks from /loop or the cron tools expire after one last run | Scheduled tasks docs |
| Whenever the machine restarts | An OS update, a restart or a power cut ends the process, and tmux with it | Any computer |
Two things the table doesn't show. First, sleep is not the end: per the docs, when the laptop wakes and gets back online, an interactive session reconnects on its own. The work simply didn't happen in between. Second, rows stack. A laptop that never sleeps still hits the login, the 7-day and the restart rows.
What that means in practice
These are reasoned from the table, not measured:
- Lunch break, lid open, on the charger, sleep timer off: the session most likely survives. The risks are a network change (rows 2 and 3) or an idle drop (row 4).
- Lunch break, lid closed, on battery: the session is frozen within moments of closing the lid. It picks up again when you open it.
- Overnight on a laptop: it depends entirely on sleep. If the laptop sleeps, the night is lost. Some Claude Code versions try to prevent idle sleep while they work, but user reports conflict (one logs sleep mid-task), so don't rely on it for an overnight run. Nothing prevents sleep on lid close.
- A weekend away: add a login check and a restart or two. Expect to come back to a session that needs
/loginor a fresh start.
Measure your own machine
You can get real numbers for your setup with a heartbeat. Start this in a second terminal tab, or a second tmux window, next to Claude Code:
while true; do date -u +%FT%TZ >> ~/claude-heartbeat.log; sleep 60; doneIt writes one line a minute. Any gap longer than a minute is time the machine was asleep or the process was stopped. After a day, look for gaps:
tail -n 50 ~/claude-heartbeat.logTo match gaps with the reason, pmset -g log | grep -E "Sleep|Wake" lists sleep and wake events on a Mac, and journalctl -b | grep -i suspend shows suspends on Linux with systemd. For the Remote Control side, start with claude remote-control --verbose and keep the log.
If you collect numbers you're happy to share, send them to support@podway.io. We'd like to replace the reasoning above with real data.
On a machine that never sleeps
Move the same session to a computer that stays on, and the first row disappears, along with closing the terminal by accident. What's left:
- Login expiry. Still there. Someone has to run
/loginbefore it runs out. - Restarts. OS updates and crashes still happen. Something has to start Claude again.
- Network and idle drops. Fewer on a data center connection than on home Wi-Fi, but row 4 is server-side and can happen anywhere.
- 7-day task expiry. Claude Code's own rule, the same on every machine.
You can build this yourself on a VPS. Our VPS + tmux guide covers the steps and the upkeep.
Where Podway fits
Podway is an always-on cloud computer for Claude Code, built for the rows that are left. If the agent crashes, Podway restarts it and Remote Control reconnects. Before your Claude login expires, Podway tells you, with a one-click reconnect. Claude runs without permission prompts on a pod, because the pod is its own isolated machine, so an unattended task doesn't stop and wait for a tap. Your files get nightly encrypted backups, kept as 7 daily and 4 weekly copies.
What it can't change: drops on Anthropic's side, and the 7-day expiry of /loop tasks. You also need your own Claude Pro or Max plan. On a Team or Enterprise plan, your org Owner has to enable Remote Control first.
Your first pod is free, no card needed, and pods start at $4/month. Start a pod, or read more on the agent computer page.
FAQ
Does Claude Code keep running when my laptop sleeps?
No. The process is frozen while the laptop sleeps. When it wakes and gets back online, an interactive session reconnects and carries on from where it was.
Is there a fixed time limit on a Claude Code session?
Not one number. The docs describe several separate limits: server mode exits after roughly 10 minutes of network outage, recurring scheduled tasks expire after 7 days, and the login has its own expiry. On a laptop, sleep usually comes before any of them.
Why does my session survive some nights and not others?
Usually power. On the charger with the lid open, many laptops stay awake. On battery or with the lid shut, they sleep. The heartbeat script above shows you which nights had gaps.
Do Claude Code cloud sessions avoid all this?
They avoid the laptop, but they have their own idle rule: after a few minutes without activity the cloud machine pauses and can later be reclaimed. Our cloud sessions comparison has the details.
Last reviewed October 26, 2026, against Anthropic's Claude Code docs. Spot something out of date? Email support@podway.io and we'll fix it.