Run Claude Code on a VPS and keep it running after you close the laptop

Short answer: install Claude Code on a Linux server and run it there, not on your laptop. Then it keeps working when the laptop sleeps. You can do this with plain tmux over SSH (below), or with SpaceApp, which puts Claude Code and other CLIs in rooms you open from a browser.

What is SpaceApp? SpaceApp is an MIT-licensed web app you run with Docker on your own machine or server. It replaces a wall of terminal windows with rooms: each room holds panes, and each pane is an AI coding CLI (Claude Code, Codex, OpenCode, Gemini CLI and others), a copilot, a browser or a tool. The rooms live on the server, so the CLIs keep running when you close the browser tab or the laptop, and you open the same rooms from any browser. Every CLI runs on your own account. Install: npx --yes run-spaceapp@latest install (Linux, macOS, Windows 11).

What you need

Option 1: tmux over SSH

ssh you@your-server
tmux new -s claude        # a session that outlives the SSH connection
claude                    # sign in on first run, then give it a task
# Ctrl-b d detaches; the task keeps running
tmux attach -t claude     # later, from any machine with SSH

This works, and it is enough for one agent. It gets harder with several agents and projects, because you open each pane to see which one is waiting for you.

Option 2: SpaceApp on the VPS

ssh you@your-server
npx --yes run-spaceapp@latest install --no-open   # installs Docker if missing, starts the stack, prints a 15-minute setup token

SpaceApp listens on 127.0.0.1:4911 on the server, which is the supported setup. From your laptop, open an SSH tunnel and use your browser:

ssh -N -L 4911:127.0.0.1:4911 you@your-server
# then open http://127.0.0.1:4911, paste the setup token, create the owner account

Add Claude Code with npx --yes run-spaceapp@latest provider install claude. Let agents work in a folder with npx --yes run-spaceapp@latest workspace add <path>. Open a Claude Code pane in a room and give it a task. When you close the tunnel or the laptop, the room keeps running on the server. Reopen the tunnel to come back.

To reach it from a phone without a tunnel, you need a reverse proxy with TLS. That proxy, access control and the firewall are then your responsibility (operations guide). Never bind SpaceApp directly to the public internet.

Keep it safe

FAQ

Does Claude Code keep running if my SSH connection drops? With tmux or SpaceApp, yes. In a plain SSH shell, no.

Can I run Codex or Gemini CLI next to it? Yes. SpaceApp runs Claude Code, Codex, OpenCode, Gemini CLI and others in panes side by side, each on your own account.

Which VPS? Any Linux server with enough CPU and RAM for the profile you choose.

Try the demo, no sign-up first.