tmux is the standard answer to "how do I keep Claude Code running after I close SSH?", and Anthropic's own docs recommend it. But plenty of people hit rendering bugs, and tmux only solves part of the problem. Here are the real options, and what each one does and doesn't cover.
The short answer
- tmux or screen keep Claude running when your terminal or SSH connection closes. They don't help if the machine sleeps, reboots, or Claude crashes.
- Background sessions (
claude --bg,claude agents) are built into Claude Code: no multiplexer, and a supervisor restarts sessions that crash. They still stop when the machine shuts down. - A systemd or launchd service starts Claude at boot and restarts it when it exits. That's the sturdy choice on a server.
- Remote Control server mode (
claude remote-control) is what you run inside any of these so you can reach the session from your phone. - A machine that never sleeps is the part none of these tools give you.
Why people look past tmux
- #29937: "Terminal rendering corruption in tmux - text overlaps and overwrites previous output", still open.
- #4851: scrollback lag in Claude Code + tmux after extended use, nearly 100 upvotes.
- On Hacker News, one reply simply says "Claude code + tmux is SO buggy. Things rendering all over the place."
- In the thread on "Tmux and Claude Code: Sessions, Send-Keys, and the Ceiling", one commenter gave up a tmux setup because "there were just too many tmux sessions to maintain".
Option 1: tmux, set up properly
tmux new -A -s claude
claude --remote-controlDetach with Ctrl-b d. new -A attaches if the session already exists, so the same command works every time. The terminal config docs suggest these lines in ~/.tmux.conf so Shift+Enter and notifications work:
set -g allow-passthrough on
set -g focus-events on
set -s extended-keys on
set -as terminal-features 'xterm*:extkeys'For flicker and jumping scrollback, the docs point to fullscreen rendering: run /tui fullscreen, or start with CLAUDE_CODE_NO_FLICKER=1 claude. In that mode, tmux search doesn't see the conversation; press Ctrl+o, then [ to write it into normal scrollback.
Good: works everywhere, survives SSH drops, and you can attach from a phone SSH app. Not covered: reboots, crashes, sleep.
Option 2: screen
screen -S claude
claude --remote-controlDetach with Ctrl-a d, reattach with screen -r claude. The Remote Control docs name tmux and screen side by side. screen is often already installed and has fewer moving parts. Same limits as tmux.
Option 3: background sessions, built in
claude --bg "fix the flaky settings test"
claude agentsPer the agent view docs, each background session "keeps running without a terminal attached". A supervisor process hosts them, restarts one that exits unexpectedly, and reconnects after the machine sleeps. Things to know:
- Shutting down still stops them. Attach or reply afterwards and they pick up from the saved conversation.
- A finished or waiting session left alone for about an hour has its process stopped to free resources. Pin it with
Ctrl+Tto keep it running. - It's a research preview. The docs don't say how background sessions interact with Remote Control, so check that before you count on reaching one from your phone.
Option 4: a systemd or launchd service
On a Linux server, let systemd start Claude at boot and restart it when it exits. Server mode draws a QR code and reads keypresses, so this runs it inside a detached tmux session you can still attach to. Save as ~/.config/systemd/user/claude-rc.service:
[Unit]
Description=Claude Code Remote Control
[Service]
Type=forking
WorkingDirectory=%h/project
ExecStart=/usr/bin/tmux new-session -d -s claude %h/.local/bin/claude remote-control
ExecStop=/usr/bin/tmux kill-session -t claude
Restart=always
RestartSec=10
[Install]
WantedBy=default.targetAdjust the claude path to what which claude prints. A user service only starts at boot, before anyone logs in, with lingering turned on (once): sudo loginctl enable-linger $USER. Then:
systemctl --user daemon-reload
systemctl --user enable --now claude-rc
sudo loginctl enable-linger $USERenable-linger lets the service run without you logged in. Restart=always matters because server mode exits on its own after roughly 10 minutes without network, per the docs. Check the paths with which tmux and which claude first.
On a Mac, the same idea is a LaunchAgent with KeepAlive, but a Mac still sleeps. Wrap the command in caffeinate -dims and keep it on power.
Good: survives reboots and crashes. Not covered: you write and maintain the unit, a restart starts a fresh session rather than resuming the old one, and an expired Claude login is still yours to notice.
Option 5: Remote Control server mode
Server mode isn't a tmux replacement. It's what makes the phone part work. One claude remote-control process serves up to 32 sessions by default (--capacity), can give each its own git worktree (--spawn worktree), and serves a crashed session again when you message it from the app (v2.1.238 or later). It still has to keep running, which is why it sits inside one of the options above.
Option 6: a machine that never sleeps
Every option above keeps a process alive on a machine. If that machine is a laptop with the lid closed, nothing runs. The fix is a computer that stays on: a desktop or mini PC at home, a VPS, or a managed one. Running Claude Code on a server covers the first two.
Which one to pick
- Laptop, tasks of an hour or two: tmux or a background session, plus
caffeinateon a Mac. - Home machine or VPS, reached from your phone: systemd plus tmux plus server mode, with Tailscale for access.
- You don't want to run a machine at all: an always-on managed computer.
Related guides
- Approve Claude Code permissions from your phone: answering prompts once the session is running.
- Tailscale + tmux + Termius, step by step: the full do-it-yourself phone setup.
- Claude Code Remote Control keeps disconnecting: sleep, network and idle drops.
If you'd rather not run the machine yourself
Podway is an always-on cloud computer for Claude Code. A pod never sleeps, and if the agent crashes, Podway restarts it and Remote Control reconnects, so there's no unit file or tmux session to babysit. You use your own Pro or Max plan and open the session from the Claude app via Remote Control. Before your Claude login expires, Podway tells you, with a one-click reconnect. On Team or Enterprise, 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 see the agent computer page.