Running AI Coding Agents on a VPS: Choosing, Logging In, Staying Up
To run Claude Code on a VPS, check the 4 GB+ RAM requirement, outbound access, headless login, and whether a stopped server still bills, in that order. Checked 2026-11-15.
- Claude Code's official requirements are Ubuntu 20.04+, Debian 10+ or Alpine Linux 3.19+ (among others), 4 GB+ RAM, an x64 or ARM64 processor and an internet connection. npm installs need Node.js 22 or later.
- On a server without a browser, open the login URL in your local browser and paste the code it shows at the Paste code here if prompted prompt. The one-year token from claude setup-token can only make model requests.
- A stopped VPS is not always a free VPS. Check each provider's billing rules before you sign up, and push your work before you delete a server.
To run an AI coding agent on a VPS, check four things in this order: the requirements (4 GB+ RAM and the rest), outbound network access, how you log in on a server with no browser, and whether the server keeps billing while it is stopped. This page is a map for those checks. It covers how to split by use case, tables of requirements and required hosts, the login flow, cost and recovery, and the order in which to read our VPS guides.
Every fact was checked against the official docs on 2026-11-15, when the latest Claude Code on npm (@anthropic-ai/claude-code) was 2.1.325. We did not run any command on this page for this hub, and we did not sign up for a VPS. Where the docs did not state something, we left it out or marked it “unverified”. We give no prices, because they change.
Split by use case
The same VPS needs different checks depending on how you use it.
| Use | How it runs | Check first | Read next |
|---|---|---|---|
| You SSH in and work interactively | SSH in and start claude inside tmux | Requirements, headless login, billing for idle hours | Run Claude Code on a VPS: SSH, tmux and Headless Login |
| An agent stays up on its own | Started by systemd or similar, unattended | Outbound access, login expiry, monitoring, where secrets live | Run an AI Agent 24/7 on a VPS |
| CI or scripts | claude -p, non-interactive | How keys are passed, whether to use --bare | Claude Code in CI, Headless and Production |
How to pick the VPS itself is in Choosing a VPS for AI Coding.
Two points from the docs matter when the agent stays up:
- An unattended session on a claude.ai login stops making progress once the login expires and can’t recover until you sign in again. The
Loginrow in/statusshows the expired state before a request fails. Source: https://code.claude.com/docs/en/authentication (checked 2026-11-15) - Background agents don’t run inside the terminal that started them. Proxy and similar variables exported only in a shell may not reach them, so put them in the
envblock of~/.claude/settings.json. Source: https://code.claude.com/docs/en/network-config (checked 2026-11-15)
Requirements
| Item | Official requirement |
|---|---|
| OS (Linux) | Ubuntu 20.04+, Debian 10+, Alpine Linux 3.19+ |
| Hardware | 4 GB+ RAM, x64 or ARM64 processor |
| Network | Internet connection required |
| Shell | Bash, Zsh and others |
| Location | Anthropic supported countries |
Source: https://code.claude.com/docs/en/setup (checked 2026-11-15)
Start from plans with 4 GB of memory or more. Smaller plans do not meet the official requirement.
- On Alpine and other musl-based distributions, the install command requires
bashandcurl. Alpine doesn’t include them by default, so the command fails withnot founduntil you install them. Source: https://code.claude.com/docs/en/setup (checked 2026-11-15) - Install with the native installer (
curl -fsSL https://claude.ai/install.sh | bash) or npm. The npm package requires Node.js 22 or later. Source: https://code.claude.com/docs/en/setup (checked 2026-11-15) claude doctorprints installation and settings diagnostics without starting a session. Source: https://code.claude.com/docs/en/setup (checked 2026-11-15)
The docs do not say how much memory several parallel sessions need (unverified).
Outbound network access
If you restrict outbound traffic with a firewall or proxy, allow at least these hosts.
| Host | Used for |
|---|---|
api.anthropic.com | Claude API requests |
claude.ai | claude.ai account authentication |
claude.com | The sign-in page opened in the browser, which redirects to claude.ai |
platform.claude.com | Console authentication, plus OAuth token exchange, refresh and revocation for claude.ai accounts |
downloads.claude.ai | Native installer, auto-updater and update checks |
registry.npmjs.org | npm installs of Claude Code, plugin installs and npx-launched MCP servers |
Source: https://code.claude.com/docs/en/network-config (checked 2026-11-15)
The official table also lists hosts such as sso.claude.com (SSO sign-in), mcp-proxy.anthropic.com (claude.ai connectors) and github.com (plugin marketplaces). Check the full table against the features you use.
- Set a proxy with
HTTPS_PROXY,HTTP_PROXYandNO_PROXY; lowercase variants also work. Source: https://code.claude.com/docs/en/network-config (checked 2026-11-15) - Claude Code does not support SOCKS proxies. Source: https://code.claude.com/docs/en/network-config (checked 2026-11-15)
- A proxy URL that can’t be parsed, such as one missing
http://, stops launch with an error. Source: https://code.claude.com/docs/en/network-config (checked 2026-11-15)
Whether a given VPS lets you filter outbound traffic by host differs by provider. We did not check each provider’s firewall features (unverified).
Logging in on a server with no browser
For interactive use, the normal login is enough.
- Run
claudeon the VPS. If the browser doesn’t open, presscto copy the login URL. - Open the URL in your local browser and sign in.
- If the browser shows a login code instead of redirecting back, paste it at the
Paste code here if promptedprompt. - The terminal shows
Login successfulwhen it is done.
Source: https://code.claude.com/docs/en/authentication (checked 2026-11-15)
The docs do not say whether the c copy reaches your local clipboard over SSH (unverified). On Linux, credentials are stored in ~/.claude/.credentials.json with file mode 0600. Source: https://code.claude.com/docs/en/authentication (checked 2026-11-15)
When to use claude setup-token, and its limits. It creates a one-year OAuth token for CI and scripts where browser login isn’t available.
- It runs the same browser authorization as
/loginand prints the token. It does not save it anywhere; set it asCLAUDE_CODE_OAUTH_TOKEN. - It authenticates with your Claude subscription and requires a Pro, Max, Ultra, Team or Enterprise plan.
- It can only make model requests. It can’t establish Remote Control sessions or fetch claude.ai connectors. Locally configured MCP servers still work.
--baredoes not read it. With--bare, useANTHROPIC_API_KEYor anapiKeyHelper.
Source: https://code.claude.com/docs/en/authentication (checked 2026-11-15)
When several credentials are present, Claude Code picks one by a fixed precedence: ANTHROPIC_API_KEY ranks above CLAUDE_CODE_OAUTH_TOKEN, and the subscription login from /login comes last. In non-interactive mode (-p), ANTHROPIC_API_KEY is always used when present. Source: https://code.claude.com/docs/en/authentication (checked 2026-11-15)
We did not try this flow on a real VPS (unverified).
Secrets and permissions
This section only points to the guides.
- Creating a non-root working user is covered in Run Claude Code on a VPS: SSH, tmux and Headless Login.
- Deny rules like
Read(./.env)don’t apply togrep -rrun without naming the file, or to Python and Node scripts that open files themselves. For enforcement across all processes, enable the sandbox. Source: https://code.claude.com/docs/en/permissions (checked 2026-11-15). The leak paths and fixes are in Keep Secrets Away from Claude Code. - In Manual mode, Claude Code asks before its file tools read or write outside the folder where it started. That boundary is a prompt, so an approved Bash command can still write anywhere your user account can. Source: https://code.claude.com/docs/en/security (checked 2026-11-15)
- For container isolation, read Run Claude Code in Docker and Dev Containers; for rule syntax, Claude Code Permissions and settings.json: A Cheat Sheet.
Cost while idle, and recovery
Hourly billing does not always mean a stopped server costs nothing. These are the two Japanese providers our VPS guides cover.
| Service | Billing | While stopped | Recovery |
|---|---|---|---|
| ConoHa VPS | Hourly with a monthly cap and no minimum term, or a 1 to 36-month prepaid discount | Billed per contracted server, running or stopped, up to the time you delete it | Free snapshots (deleted after 24 hours), paid automatic backups (daily, up to 30 generations), saved images |
| XServer VPS (single server) | No hourly billing listed on the official page | Unverified | Automatic backup column shows ”—” |
| XServer VPS Cloud | No hourly billing listed on the official page | Unverified | Daily automatic backups (up to 7 days) |
Source: https://vps.conoha.jp/ (checked 2026-11-15) Source: https://support.conoha.jp/vps/faq/vps-q/service-q/ (checked 2026-11-15) Source: https://support.conoha.jp/v/deletevps/ (checked 2026-11-15) Source: https://vps.xserver.ne.jp/ (checked 2026-11-15)
To stop ConoHa VPS billing, delete the server; a deleted server can’t be recovered. XServer’s page suggests 2 GB for personal or test use, 4 GB for development and operation together, and 8 GB for several services. Source: https://vps.xserver.ne.jp/ (checked 2026-11-15). Claude Code needs 4 GB+, so the 2 GB plan does not meet its requirement.
For any provider, check on the official pages:
- whether billing is hourly or monthly, and whether a stopped server still bills
- whether snapshots or automatic backups exist, and whether they cost extra
- whether a long-term prepaid contract ends when you delete the server
Restoring a backup or deleting a server loses the most recent work on it, so push to a remote repository often. Prices and plans change; confirm them on the official pages before you sign up. How we compare these points across providers is in Choosing a VPS for AI Coding.
Reading order
Starting points, not a ranking. New to running agents on a VPS? Read top to bottom.
- Choosing a VPS for AI Coding: pick a VPS by requirements, outbound access, billing and recovery.
- Run Claude Code on a VPS: SSH, tmux and Headless Login: SSH keys, a working user, install, headless login and keeping work alive in tmux.
- Run an AI Agent 24/7 on a VPS: keep an agent up with systemd and catch the “green but stalled” state.
From the neighboring pillars, also read Run Claude Code in Docker and Dev Containers (container isolation) and Keep Secrets Away from Claude Code (keeping keys out of sight).
Related hubs
- Claude Code in CI, Headless and Production:
claude -p,--bareand where keys live in CI. - Claude Code Setup and Daily Operations: where settings live and which wins.
- MCP Servers in Claude Code, Codex and Gemini CLI: MCP servers on a remote machine.
- Claude Code Subagents and Parallel Agents: splitting work on one machine.
- AI Coding Tools Compared: Plans and Prices (2026): plans and prices.
Summary
- On a VPS, check requirements, outbound access, login and idle billing, in that order.
- The official requirements are 4 GB+ RAM, x64 or ARM64, and an OS such as Ubuntu 20.04+. npm installs need Node.js 22+.
- If you filter outbound traffic, allow
api.anthropic.com,claude.ai,claude.com,platform.claude.comanddownloads.claude.ai(registry.npmjs.orgfor npm). SOCKS proxies don’t work. - Without a browser, open the URL locally and paste the code back. A
claude setup-tokentoken is for model requests only. - A stopped server may still bill. Check billing and backups on the official pages, and push before you delete.
- Checked against the official docs on 2026-11-15; we ran nothing.
FAQ
- How much memory does a VPS need to run Claude Code?
- The official requirement is 4 GB+ RAM, with an x64 or ARM64 processor, an OS such as Ubuntu 20.04+, Debian 10+ or Alpine Linux 3.19+, and an internet connection. The docs do not say how much memory parallel sessions need.
- Which hosts must a VPS firewall allow for Claude Code?
- api.anthropic.com, claude.ai, claude.com and platform.claude.com. The native installer and auto-updater also use downloads.claude.ai, and npm installs need registry.npmjs.org. SOCKS proxies are not supported.
- How do I log in to Claude Code on a VPS without a browser?
- If the browser does not open, press c to copy the login URL and open it in your local browser. If the browser shows a login code instead of redirecting back, paste it at the Paste code here if prompted prompt. On Linux, credentials are stored in ~/.claude/.credentials.json with file mode 0600.
- What can't a claude setup-token token do?
- It can only make model requests, so it can't establish Remote Control sessions or fetch claude.ai connectors. It requires a Pro, Max, Ultra, Team or Enterprise plan, and --bare runs do not read it.