How to Run Claude Code in the Cloud (24/7, From Any Device)

Two ways to run Claude Code on a server that never sleeps: a managed platform ready in 30 seconds, or your own VPS with tmux. Full setup guide for both, plus Git, MCP, and long-running sessions.

How to Run Claude Code in the Cloud (24/7, From Any Device)

To run Claude Code in the cloud, you have two options: use a managed platform like host4.ai (ready in 30 seconds, from $5/month) or set up your own VPS with tmux (a few hours of work, $12–24/month). Either way, Claude Code runs on a server that never sleeps — you can close your laptop, lose Wi-Fi, or check on your agent from your phone, and it just keeps working.

This guide covers both paths in detail: the 5-minute managed setup, the full DIY server setup with every command you need, plus how to handle Git, MCP servers, and long-running sessions in the cloud. By the end you'll have Claude Code running 24/7, accessible from any device.

Why run Claude Code in the cloud at all?

Claude Code is a terminal program. By default it runs on your laptop, which means it lives and dies with your laptop. Running it on a cloud server changes the entire workflow:

The problem with running Claude Code locally

If you've used Claude Code on your laptop for more than a week, you've probably hit most of these:

Local vs cloud: quick comparison

AspectLocal (laptop)Cloud server
Session survives closing laptopNoYes
Runs while you sleepNoYes
Access from phoneNoYes
Built sites are instantly publicNo (localhost)Yes (real URL + SSL)
Uses your CPU/batteryYesNo
Safe to run with full permissionsRiskyIsolated environment

Method 1: host4.ai — Claude Code in the cloud in 5 minutes

host4.ai gives you a dedicated Ubuntu environment with Claude Code (and Codex) pre-installed, a browser terminal, and a live domain — no server administration at all. Here's the full setup:

Step 1: Create your account (30 seconds)

Go to host4.ai and sign in with Google. No credit card required — you get 20 free AI messages to try everything.

Step 2: Pick your subdomain

Choose a name during onboarding. Your environment lives at yourname.host4.ai with free SSL. Anything Claude builds is immediately live at that address. You can attach a custom domain later.

Step 3: Open the terminal

Choose Terminal mode and you get a full Linux terminal in your browser tab — a real Ubuntu environment, not a simulation. Claude Code is already installed. Run:

claude

Log in with your Anthropic account (or use host4.ai's built-in AI credits if you don't have one), and you're coding. That's the entire setup.

Step 4: Give it work and walk away

Ask Claude to build your app, refactor your codebase, or set up a cron job. Then close the tab. Seriously — the session keeps running on the server. Reopen the terminal from any device, any time, and you're back exactly where you left off.

Step 5: Check in from your phone

The browser terminal works on mobile, with adjustable font size and quick-action keys. Reviewing your agent's progress from the couch or the train actually works.

What you also get

Plans start at $5/month, and there's a $99 lifetime deal (pay once, use forever). Compare that with the DIY route below.

Method 2: DIY — your own VPS with tmux

If you'd rather manage the server yourself, here's the complete setup on a fresh Ubuntu VPS (Hetzner, DigitalOcean, or any provider — expect $12–24/month for something comfortable).

1. Provision and secure the server

ssh root@your-server-ip
adduser dev && usermod -aG sudo dev
# set up SSH keys, disable password login in /etc/ssh/sshd_config
apt update && apt upgrade -y
ufw allow OpenSSH && ufw enable

2. Install Node.js and Claude Code

curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs
npm install -g @anthropic-ai/claude-code

3. Keep sessions alive with tmux

This is the critical piece. Without tmux, your session dies the moment SSH disconnects:

sudo apt install -y tmux
tmux new -s claude     # start a persistent session
claude                 # run Claude Code inside it

Detach with Ctrl+B then D. Log out, close your laptop — the session keeps running. Reattach later from anywhere:

tmux attach -t claude

4. What you're signing up for

The DIY route works, but you own everything that comes with a public server: security patches, firewall rules, SSL certificates, web server config if you want to serve what Claude builds, backups, and monitoring. Budget a few hours for initial setup and ongoing time for maintenance. If that sounds fun — go for it. If it sounds like a distraction from actually building, use a managed platform. (We wrote a more detailed take on this trade-off in How to Run Claude Code 24/7.)

Using Git and GitHub from your cloud environment

Your cloud environment should be a first-class Git citizen. Two clean options:

# Option A: GitHub CLI (easiest)
gh auth login
git clone https://github.com/you/your-repo

# Option B: SSH deploy key
ssh-keygen -t ed25519 -C "claude-cloud"
cat ~/.ssh/id_ed25519.pub   # add this to GitHub → Settings → SSH keys

From there, Claude Code can clone, branch, commit, and push like on any machine. A common workflow: ask Claude to implement a feature, review the diff from your phone, then tell it to push and open a PR.

Running MCP servers in the cloud

MCP (Model Context Protocol) servers work the same way in a cloud environment as locally — often better, because the server has a stable, always-on connection:

claude mcp add playwright -- npx @playwright/mcp@latest

Database MCPs, browser automation, API integrations — they all run alongside Claude on the server and stay available across sessions.

Long-running tasks: the real payoff

The moment cloud hosting clicks is the first time you give Claude a genuinely big task and leave:

Tips for long sessions: give clear completion criteria ("run the tests, iterate until they pass"), ask Claude to keep a progress log file you can check remotely, and break huge tasks into checkpoints so you can review direction midway.

Cost comparison

OptionMonthly costSetup timeMaintenance
host4.aifrom $5 (or $99 once, lifetime)30 secondsNone
DIY VPS + tmux$12–242–4 hoursYours: security, SSL, backups
Laptop (local)"free"0Sessions die constantly

Note that AI usage is separate in all cases: you either bring your own Anthropic subscription/API key, or on host4.ai you can use built-in credits without an Anthropic account at all.

FAQ

Do I need an Anthropic subscription to run Claude Code in the cloud?

On a DIY VPS, yes — you log in with your own Anthropic account or API key. On host4.ai you can do that too, or use the platform's built-in AI credits with no Anthropic account.

Does Claude Code behave differently in the cloud?

No. It's the exact same CLI running on Linux. Same commands, same config files, same MCP support. The only difference is that the machine underneath never turns off.

Can I really close the browser tab mid-task?

Yes. On host4.ai the terminal session runs server-side; the tab is just a window into it. On a DIY setup, the same is true as long as Claude runs inside tmux or screen.

Is it safe to run Claude Code with full permissions in the cloud?

Safer than locally. host4.ai environments are isolated from each other, so an agent with broad permissions can only affect its own environment — not your personal files, keys, or other projects.

Can I access my environment from my phone?

Yes — that's one of the main reasons to do this. host4.ai's browser terminal is mobile-optimized. On DIY, you'll need an SSH client app like Termius, which works but is clunkier.

What happens to my files if the session crashes?

Files live on the server's disk, not in the session. If Claude crashes, restart it and continue — your project directory, git history, and CLAUDE.md context are all still there.

Can I host what Claude builds on the same server?

On host4.ai, that's the default: everything is live at yourname.host4.ai (or your custom domain) the moment it's written. On a DIY VPS you'll need to configure nginx/Caddy and DNS yourself.

Claude Code or Codex?

Both work in the cloud, and host4.ai has both pre-installed — you can even use them on the same project. Claude Code is the more capable agent for most coding work as of 2026.

Start now

The fastest path: create a free host4.ai environment — sign in with Google, pick a subdomain, open the terminal, run claude. You'll have Claude Code running in the cloud, on a live URL, before a DIY server would finish its first apt upgrade. No credit card, 20 free AI messages included.

Build your next project with AI

Get a cloud workspace with Claude Code pre-installed. Your AI agent builds it, we host it.

Start for $5/month