Claude Code on a VPS: Run It 24/7 and Reach It From Your Phone

Yes, you can run Claude Code on a VPS, and it's the cleanest way to keep it working with your laptop closed. Rent a small Linux server and set it up yourself, or use AFK Pilot Cloud, a managed machine with Claude Code preinstalled, in preview. Anthropic's own Remote Control lets a phone drive a session, but the session still lives on a machine that has to stay awake.

I build AFK Pilot, which runs Claude Code next to five other coding agents, and it has over 210,000 installs. Last updated: November 29, 2026.

Claude Code chat in AFK Pilot: Opus 5.5, Sonnet 5.5 and Haiku 5.5 in the picker, effort Low to Max
Claude Code in AFK Pilot on Opus 5.5 at Extra high, with part of the model list open. Invented project.

Open afkpilot.com

At a Glance

  • The machine. A Linux VPS on KVM, sized for your project's builds, not for the CLI.

  • The account. A Claude Pro, Max, Ultra, Team or Enterprise plan, or an API key billed separately.

  • The sign-in. Under Anthropic's terms, it completes on the server itself. Copying a token from your laptop is out.

  • The phone. An SSH app, Anthropic's Remote Control running on the VPS, or a browser UI.

Set Up Your Own VPS

  1. Rent a KVM VPS, not OpenVZ or a shared container, so the agent can install whatever the project needs. Ubuntu 24.04 LTS, with 2 vCPU and 4 GB of RAM as a comfortable floor for a web app.

  2. Create a user. Don't run an agent as root: adduser dev && usermod -aG sudo dev.

  3. Install Claude Code. curl -fsSL https://claude.ai/install.sh | bash installs the native binary, which updates itself. On Node.js 22 or later, npm install -g @anthropic-ai/claude-code gets the same binary (Anthropic says not to run it with sudo). Platform notes: Anthropic's setup page.

  4. Sign in on the server. Run claude auth login, open the URL it prints on your phone or laptop, sign in, and paste Anthropic's code back into the terminal. claude auth status prints {"loggedIn": true} when it worked.

  5. Keep it running. Start Claude inside tmux (tmux new -s claude) so a dropped SSH connection doesn't end the run, or as a systemd user service to have it back after a reboot.

  6. Get your code on it. Clone with the GitHub CLI (gh auth login, then gh repo clone owner/repo) or a deploy key. Private repositories need one or the other.

What Anthropic's Terms Allow

Hosting is allowed. Anthropic's legal and compliance page says nothing prevents "an end user from signing in to the unmodified Claude Code binary with their own Claude subscription, including where a platform hosts Claude Code." The conditions: an unmodified binary, no sign-in method removed, and nobody collecting, storing or intermediating Claude.ai credentials or session tokens. Sign-in must "complete through Anthropic's own flow," so step 4 runs on the VPS.

Reach It From Your Phone

  • A terminal app over SSH. Termius, Blink or any SSH client, then tmux attach. Fine for checking in, tiring for steering on a 6-inch screen.

  • Anthropic's Remote Control, on the VPS. Run claude remote-control in the project directory inside tmux, and open the session URL on your phone. Remote Control needs a Pro, Max, Ultra, Team or Enterprise login, not an API key. It's what I'd use on a VPS I ran myself.

  • A browser UI. AFK Pilot (extension ID grok-vscode-phuryn) gives Claude Code permission cards, diffs and a file panel in any browser. The extension needs an editor window, so on a server, that's AFK Pilot Cloud.

The Managed Route: AFK Pilot Cloud

AFK Pilot Cloud is the VPS above, done for you, with the browser UI attached. It's a dedicated Linux machine for your account, with 8 CPU cores, 8 GB of RAM, about 100 GB of disk, and Claude Code, Codex, Grok Build and Muse Code preinstalled. It's in preview. Under the hood each one is a Fly.io Sprite, a stock Ubuntu virtual machine with a writable disk that suspends between sessions.

AFK Pilot Cloud: a phone and a laptop browser reaching a dedicated cloud machine with the agents preinstalled
The managed route: AFK Pilot Cloud is a dedicated machine you reach from a phone or any browser.
  • It persists. Repositories, packages, dotfiles and agent sign-ins stay between sessions. It sleeps after about ninety seconds of quiet and usually wakes in seconds. One built from scratch can take up to 25 minutes.

  • Anthropic's sign-in. You run Claude's own login on the machine from the browser and paste Anthropic's code back. The token lands on the machine.

  • Claude Code's Auto mode by default. New conversations start in Auto mode, one of Claude Code's own permission modes (not AFK Pilot's Auto accept), unless you pick another.

  • Connectors (MCP apps) work, signed in from the browser.

  • No automatic backups. A machine can be rebuilt or reclaimed when a preview ends, a subscription lapses or maintenance needs it, so push anything you care about to a Git remote.

The service stores nothing about your Claude account: the token never passes through the relay, and the one-time code passes through it once and isn't stored. With a linked phone, prompts, replies and the files you open remotely pass through the AFK Pilot relay in memory, over TLS, and are never stored. They're not end-to-end encrypted. AFK Pilot runs the machine, so your privacy there rests on its policy.

Remote control from your phone is free for one linked device and 100 messages a week. Remote Max, $5 a month, removes those limits and includes AFK Pilot Cloud while it's in preview. Cloud will get a plan of its own later.

FAQ

Can Claude Code run 24/7?

On a machine that stays on, yes. Nothing in the CLI needs a display, and tmux or a service keeps the process alive.

Does Claude Code keep running when I close my laptop?

Not on the laptop. A closed laptop lid can suspend it, and Anthropic's Remote Control reconnects only when the machine is back online. That's what a VPS, or the Cloud machine, is for.

Does Claude Code support remote control?

Yes. Anthropic's Remote Control works on Pro, Max, Ultra, Team and Enterprise plans (on Team and Enterprise an Owner turns it on first), not with API keys. The claude process has to keep running. AFK Pilot's remote control works with an API key too (ANTHROPIC_API_KEY).

Can I copy my login from my laptop to the server?

No. Anthropic's terms require the sign-in to complete through their own flow on the machine where Claude runs. Run claude auth login on the server.

Is running Claude Code on a VPS or remote server allowed by Anthropic's terms?

Yes, for an end user signing in to the unmodified binary with their own subscription, including where a platform hosts it. Intermediating credentials or reselling usage isn't.

Do I need Node.js?

Not with the native installer. The npm route needs Node.js 22 or later and runs the same native binary.

How much RAM does Claude Code need on a VPS?

The CLI is light. 4 GB is a comfortable floor for a web app's builds and tests, which is why the Cloud machine has 8.

Can I use my Claude Max subscription on a VPS?

Yes. That's the case Anthropic describes, and your plan's rate limits apply wherever the CLI runs.

KVM or Docker?

Docker runs the CLI fine, but the agent installs tools and runs builds, and a KVM virtual machine with root is less friction for that.

Can I run Codex, Grok Build or Muse Code the same way?

Yes. Codex signs in by device code where its CLI and your account allow it, Grok Build by device code always, and Muse Code through Meta's link and a short code. All four are preinstalled on the Cloud machine. The Grok side: Grok Remote Control.

Is there managed Claude Code hosting, so I can skip the setup?

Most "Claude Code VPS hosting" plans say self-managed in the fine print: the VPS above with a template. Claude Code on the web runs in Anthropic's sandbox on a clone of your repository, not on a machine you keep. AFK Pilot Cloud is the managed version, in preview, and you still sign in to Claude on it yourself.


Open afkpilot.com

Install AFK Pilot for VS Code

Download AFK Pilot Desktop

AFK Pilot has over 210,000 installs across the VS Code Marketplace and Open VSX (November 2026). I'm Paweł Huryn, I build it, and I write The Product Compass, a newsletter with 142,000 subscribers.

AFK Pilot is an independent community project, not affiliated with or endorsed by SpaceXSI (formerly xAI), Meta, DeepSeek, OpenAI, Anthropic or Google. Grok and Grok Build are trademarks of SpaceXSI; Muse Code of Meta; DeepSeek of DeepSeek; Codex of OpenAI; Claude and Claude Code of Anthropic; Antigravity and Gemini of Google.