# How do I keep Claude Code running 24/7 and control it from my phone?

> Run Claude Code on a machine that stays on, in a terminal session that survives disconnects, and reach it from your phone with Remote Control or a browser terminal.

- Source: Sanbox knowledge base, by Sanlabs GmbH
- URL: https://sanbox.cloud/kb/coding-agents/claude-code-24-7-from-your-phone/
- Type: how-to
- Section: Coding agents in the cloud
- Language: en
- Published: 2026-11-06
- Updated: 2026-11-06

Claude Code only works while the machine running it stays on, so 24/7 means moving it off your laptop. Anthropic offers cloud sessions, which run on Anthropic's VMs and can be started from the Claude app, and Remote Control, which lets the Claude app steer a session that keeps running on your own computer. The do-it-yourself way is a VPS with tmux and a private network such as Tailscale. On Sanbox, you install Claude Code on an OpenCode Computer, which stays running until you stop it, and reach it from your phone through the console's browser terminal or Remote Control.

## Run this with your agent

```text
Read https://sanbox.cloud/kb/coding-agents/claude-code-24-7-from-your-phone.md and follow it to run Claude Code on an always-on Computer.
If the Sanbox CLI is missing, install it with `npm install -g @sanlabs/sanbox-cli@latest`
and sign in with `sanbox login`. Show me each command before you create, stop or delete a Computer.
```

## Which option fits?

| Option | Where Claude Code runs | Keeps running when your laptop sleeps | Phone access | Work for you |
|---|---|---|---|---|
| Cloud sessions | Anthropic-managed VM | Yes, until the session goes idle and its VM is reclaimed | Claude app, Code tab | Connect GitHub |
| Remote Control | Your own computer | No, that computer has to stay on | Claude app or claude.ai/code | Almost none |
| VPS with tmux and Tailscale | Your server | Yes | An SSH app over Tailscale | Patching, firewall, backups |
| Sanbox Computer | A Firecracker microVM with its own disk | Yes, until you stop it | Console terminal or Remote Control | A template and an install |

Anthropic's options are often enough. Cloud sessions suit tasks on a GitHub repository that end in a branch or pull request, and they need no machine of your own. Remote Control suits you if your desk computer is on anyway. A Computer helps when you want a machine that isn't your laptop, keeps its disk across stops, and reaches only the hosts you allow.

## Steps

### 1. Allow the hosts Claude Code needs

Computers deny outbound traffic by default. Save this as `claude-code-policy.json`:

```json
{
  "default_action": "deny",
  "rules": [
    { "destination": "registry.npmjs.org", "ports": [{ "from": 443, "to": 443 }] },
    { "destination": "api.anthropic.com", "ports": [{ "from": 443, "to": 443 }] },
    { "destination": "claude.ai", "ports": [{ "from": 443, "to": 443 }] },
    { "destination": "platform.claude.com", "ports": [{ "from": 443, "to": 443 }] },
    { "destination": "github.com", "ports": [{ "from": 443, "to": 443 }] }
  ]
}
```

Per Claude Code's network table, `registry.npmjs.org` serves the npm install, `api.anthropic.com` the model calls, and `claude.ai` and `platform.claude.com` the sign-in. `github.com` is only for cloning; drop it if you copy your code in.

### 2. Create and start an OpenCode Computer

The OpenCode Computer image already has Node 22 and the zellij terminal multiplexer. Its own OpenCode agent needs a model provider, so pick one your organisation has connected:

```bash
sanbox model-providers list --json
sanbox templates create --name "Claude Code" --type opencode-computer \
  --model-provider <provider-id> --model <model-id> \
  --network-policy claude-code-policy.json --json
sanbox templates validate <template-id> --json
sanbox run --template <template-id> --external-run-id claude-code-main --json
sanbox runs get <run-id> --json
```

Wait until the run's state is `running`. Don't add `--wait` to `sanbox run`: for a Computer it waits for the Computer to stop.

### 3. Install Claude Code

```bash
sanbox exec <run-id> --root -- npm install -g @anthropic-ai/claude-code
sanbox exec <run-id> -- claude --version
```

The npm package needs Node 22 or later. Claude Code's docs advise against installing with `sudo`, because an install that needs root can't update itself. Update it yourself by rerunning the first command with `@anthropic-ai/claude-code@latest`.

### 4. Start Claude Code in a session that survives disconnects

Open the run in the [console](https://console.sanbox.cloud) and open a terminal. Each console terminal is its own zellij session: closing the browser tab or losing the network leaves it running, and reopening the terminal brings back the same screen and scrollback. Closing the terminal itself in the console ends it. The [terminal post](https://sanbox.cloud/blog/building-a-persistent-browser-terminal/) explains how this works.

```bash
cd /workspace
git clone https://github.com/<owner>/<repo>.git
cd <repo>
claude
```

For a private repository, copy a local checkout in from your machine with `sanbox cp ./<repo> <run-id>:/workspace` instead.

Claude Code prints a sign-in URL. Open it on your phone or laptop, sign in, and paste the code it shows back into the terminal. [Logging in on a headless machine](https://sanbox.cloud/kb/coding-agents/log-in-to-claude-code-or-codex-on-a-headless-machine/) covers tokens and API keys.

From your own terminal, you can use SSH instead: run `sanbox ssh <run-id>`, then `zellij attach --create claude` inside the Computer, and start `claude` there. The console terminal and SSH sessions can use different home directories, so sign in from the one you'll keep using.

### 5. Control it from your phone

- **Console terminal.** Open console.sanbox.cloud in your phone's browser, open the run and reopen the same terminal. It's a full terminal, so check how it works with your phone's keyboard before you rely on it.
- **Remote Control.** In the running Claude Code session, type `/remote-control`, or start Claude Code with `claude --remote-control`. Then open the Claude app, tap Code and pick the session. Remote Control needs a claude.ai sign-in on a Pro, Max, Ultra, Team or Enterprise plan; API keys and `claude setup-token` tokens can't start it. On Team and Enterprise, an Owner has to turn it on first.

Remote Control makes outbound HTTPS requests only, so the Computer opens no inbound port. If it can't connect, check Claude Code's network table for a host your policy is missing. Its usual catch, that your own computer has to stay on, doesn't apply here: the Computer stays on.

### 6. Stop it when you're done

```bash
sanbox runs stop <run-id> --wait --json
sanbox runs resume <run-id> --wait --json
```

Stop ends every process, including Claude Code, and keeps the disk: your repository, the install and Claude Code's settings. After a resume, open a terminal in your repository and run `claude --continue` to pick up the last conversation.

## Lock down egress

Add hosts only when a task needs them. The other hosts in Claude Code's network table are for optional features such as plugins, release notes and telemetry. Package registries your project uses, such as `pypi.org`, need their own rules. A blocked request names the host it couldn't reach.

## Snapshot it

To reuse this setup, stop the Computer once Claude Code is installed and your repository is in place, before you sign in, and save it as a snapshot. Computers started from it skip the install and don't carry your login:

```bash
sanbox runs stop <run-id> --wait --json
sanbox snapshots create --run <run-id> --name claude-code-base --wait
sanbox run --snapshot claude-code-base --json
```

## What this doesn't do

- It doesn't keep processes through a stop. RAM and running commands end; only the disk is kept.
- Nothing stops or sleeps the Computer for you, and [scheduled runs](https://sanbox.cloud/kb/parallel-work/schedule-a-recurring-agent-job/) are enabled on request. A running Computer stays on until you stop it, and it counts toward your organisation's plan.
- It doesn't change Claude Code's usage limits or billing. Those stay with your Anthropic plan or API key.
- Claude Code's model calls go from the Computer straight to Anthropic, under your agreement with Anthropic.
- There's no dedicated Claude Code template. You install it yourself as above.

## Related

- [How do I run Claude Code on a cloud computer that keeps its files?](https://sanbox.cloud/kb/coding-agents/claude-code-on-a-cloud-computer-that-keeps-files/)
- [How do I log in to Claude Code or Codex on a headless server?](https://sanbox.cloud/kb/coding-agents/log-in-to-claude-code-or-codex-on-a-headless-machine/)
- [Claude Code on the web vs your own cloud computer](https://sanbox.cloud/compare/claude-code-on-the-web-vs-your-own-cloud-computer/)
- [What survives when an agent's computer stops?](https://sanbox.cloud/kb/agent-computers/what-survives-a-stop/)

## Sources

- Claude Code docs, [Advanced setup](https://code.claude.com/docs/en/setup): npm install, Node 22, the advice against `sudo` installs. Checked 2026-11-06.
- Claude Code docs, [Enterprise network configuration](https://code.claude.com/docs/en/network-config): required hosts. Checked 2026-11-06.
- Claude Code docs, [Remote Control](https://code.claude.com/docs/en/remote-control): plans, commands, outbound-only connections, tmux on remote machines. Checked 2026-11-06.
- Claude Code docs, [Use Claude Code in the cloud](https://code.claude.com/docs/en/claude-code-on-the-web): cloud sessions, plans, idle expiry. Checked 2026-11-06.
- Claude Code docs, [Authentication](https://code.claude.com/docs/en/authentication): sign-in flow and `claude setup-token` limits. Checked 2026-11-06.
- Tailscale docs, [Tailscale SSH](https://tailscale.com/kb/1193/tailscale-ssh): SSH within a tailnet without a public SSH port. Checked 2026-11-06.

## Next step

Talk to us at sales@sanlabs.ai. Sanlabs' forward-deployed engineers build agent use cases with your team, with experience in aviation, pharmaceuticals, supply chain and logistics, and internal admin workflows. How we work: https://sanbox.cloud/kb/teams/forward-deployed-engineering.md

Existing customers can use Sanbox from a coding agent: install the CLI with `npm install -g @sanlabs/sanbox-cli@latest`, sign in with `sanbox login`, then run `sanbox skill` for the full agent guide.
