99.9% Uptime SLA

How to Run Claude Code on a VPS

This guide explains how to run Claude Code on a VPS so the runtime can live in a persistent remote environment instead of depending on a local machine. Virtarix provides the VPS infrastructure: NVMe storage, full root access, global locations, and an always-on server environment. You bring your own Claude Code access, repository permissions, project credentials, tools, and configuration.

Trustpilot rating: 4.5 out of 5

Who This Guide Is For

This page is for users who want Claude Code work to run from a controlled VPS workspace instead of relying only on a local desktop session.

01

Developers who want a remote coding-agent workspace

Use a VPS when repositories, branches, package managers, and terminal sessions need a stable server location.

02

Teams testing agent changes away from local workstations

Keep coding-agent experiments, build output, and test logs away from sensitive workstation files.

03

Users who need repository state and logs on a server

Keep project files, run history, generated artifacts, and troubleshooting evidence in one reachable environment.

04

Technical operators managing Claude Code authentication themselves

Virtarix supplies self-managed VPS infrastructure; you handle Claude Code authentication, installation, updates, monitoring, and security.

What You Need Before You Start

Before selecting a plan or installing Claude Code, confirm the server access, runtime path, credentials, firewall exposure, and recovery routine needed for the deployment.

Choose the Claude Code Runtime Path

Before running commands, decide how Claude Code should be installed, updated, restarted, and recovered on the VPS. Use current upstream documentation as the authority for exact versions and flags.

Native installer

Recommended for a normal Linux VPS install path where Claude Code should run from the remote server workspace.

Package repositories

Useful when operations policy prefers apt, dnf, or apk based upgrades and key verification.

npm package

Useful when Node is centrally managed and optional dependencies are allowed.

Scripted non-interactive use

Useful for reviewed automation wrappers that run one task and exit, after authentication, permissions, current CLI flags, and repository boundaries have been verified.

Recommended VPS Requirements

Minimum starting point for a test environment:

Minimum starting point for a test environment

Use this to validate the workflow before committing to an always-on deployment.

  • 2 CPU cores
  • 4 GB RAM
  • 30 GB NVMe storage
  • Ubuntu VPS or another supported Linux server
  • Root access

Recommended Virtarix starting point

Cloud VPS S

$5.50/month

Recommended Virtarix starting point:

  • Cloud VPS S at $5.50/month
  • 3 CPU cores
  • 6 GB RAM
  • 50 GB NVMe storage
  • Unlimited bandwidth
  • 1 snapshot
  • 1 Backup slot
  • IPv4 + IPv6

Recommended Architecture

The VPS is the runtime layer. You connect over SSH, configure Claude Code, keep logs and runtime state on the server, and control API or model provider access yourself. For sizing context, return to Claude Code VPS hosting before moving from test to production use.

User

Operator or developer controlling the workflow.

SSH

Secure access into the server.

Virtarix VPS

Runtime, storage, network, and package layer.

Claude Code runtime

Claude Code runtime layer for the workflow.

API/model provider

External model access and provider credentials.

Repositories, tools, and integrations

Code, automation tools, messaging gateways, and webhooks.

Step-by-Step Setup Flow

Follow this sequence as a practical deployment checklist, but confirm Claude Code-specific versions, installer flags, and service commands against current official documentation before production use.

Deploy and connect

Prepare the VPS, connect over SSH, and create a clean workspace before installing Claude Code and project-specific dependencies.

Deploy the VPS

Choose Ubuntu or another Linux distribution supported by Claude Code. Select the location closest to the user, app, API provider, or team where practical, and start with enough CPU, RAM, and storage for persistent background work.

Connect over SSH

ssh root@YOUR_SERVER_IP

Update the server

sudo apt update && sudo apt upgrade -y

Create a non-root user where practical

Log back in as the non-root user before continuing if your security policy requires it.

adduser deployusermod -aG sudo deploy

Prepare a private runtime workspace

Create one directory tree for Claude Code config examples, working files, logs, and backups. Keep secrets out of shell history and commit only templates, not real keys.

APP_HOME="$HOME/run-claude-code-on-vps-runtime"mkdir -p "$APP_HOME/config" "$APP_HOME/workspace" "$APP_HOME/logs" "$APP_HOME/backups"chmod 700 "$APP_HOME/config"printf '%s\n' "# add real provider keys privately" > "$APP_HOME/config/env.example"chmod 600 "$APP_HOME/config/env.example"

Install and configure

Install base packages, follow the current upstream install path, and configure runtime/environment settings.

Install base dependencies

sudo apt install -y git curl wget unzip ca-certificates gnupg

Install runtime dependencies

Claude Code official setup lists native installation, Linux package repositories, and an npm package option. Node.js may still be relevant for your projects or for the npm install path, but the installed claude binary itself should be treated as the coding tool, not as a long-running web service. Use official Claude Code documentation to confirm exact versions before relying on the server setup.

Install or clone Claude Code

Claude Code official setup documents several supported platforms, but this VPS guide should follow the Linux server path first. Install Claude Code, confirm the CLI, then complete the interactive login or provider flow before starting work in a project directory.

# Linux install command from Claude Code quickstartcurl -fsSL https://claude.ai/install.sh | bash# Confirm the CLI is available, then authenticate interactivelyclaude --versionclaude

Configure authentication and project secrets

For Claude Code, authenticate through the documented account or provider flow first. Keep project-specific secrets in the project’s normal secret-management path, not in a generic .env created only for Claude Code.

claude --versionclaude doctorclaude

Start Claude Code

Claude Code is normally started inside the repository workspace as an interactive terminal coding session. Use a service manager only for a separate wrapper or automation that you have designed and secured; do not present Claude Code itself as a generic daemon.

# Example repository workflow after authenticationgit clone YOUR_REPOSITORY_URLcd YOUR_REPOSITORY_DIRECTORYclaude

Run, secure, and maintain

Keep the VPS workspace reachable, secure SSH and project access, validate Claude Code authentication, and maintain the project environment over time.

Keep It Running

Claude Code is usually an interactive terminal process, not a background service. Keep the VPS available over SSH, use tmux or screen when you need a resilient terminal session, and reserve Docker/systemd for separate project services or explicitly designed headless automation wrappers.

tmux new -s claude-codecd YOUR_REPOSITORY_DIRECTORYclaude

Secure the VPS

Use SSH keys where possible, restrict password login if appropriate, enable a firewall, expose only the ports your project actually needs, protect project secret files and Claude authentication state, keep packages updated, and use backups or snapshots before major changes.

Test the Setup

Confirm claude --version and claude doctor pass, authenticate successfully, open a repository, run a small controlled prompt, restart the SSH session, and confirm the workspace and credentials behave as expected.

Maintain It Over Time

Review Claude Code logs, rotate keys when needed, monitor disk usage, monitor RAM and CPU usage, update framework dependencies, snapshot before upgrades, and keep rollback notes.

Why Claude Code Benefits from a VPS

Claude Code benefits from a VPS when project files, Git branches, build tools, and terminal sessions should live in a server environment that can be reached over SSH.

01

Remote development workspace

Keep project repositories, dependency installs, generated files, terminal history, and build logs on an always-on server.

02

Cleaner separation from local files

Use the VPS as a deliberate coding-agent boundary instead of mixing experiments with personal files and local credentials.

03

Reproducible server context

Document the packages, runtimes, users, firewall rules, and repository paths that make the Claude Code environment work.

04

Controlled authentication and access

Treat the VPS as a clean development machine. Keep SSH access tight, use project-specific repositories, and avoid storing more credentials on the server than the coding workflow requires.

Security Basics for Claude Code on a VPS

Treat the Claude Code server as a privileged runtime. Security should be part of the setup, not a later cleanup task.

Warning

Privileged runtime

The server can contain Claude access, repositories, terminal sessions, project secrets, build output, and runtime logs. Harden it before production use.

Troubleshooting

Common setup problems to check before blaming the VPS or framework.

SSH issues

SSH connection refused

Server firewall, wrong IP, or SSH service unavailable Confirm the VPS is running, check the IP, and verify port 22 or your configured SSH port.

Permission denied over SSH

Wrong key, wrong user, or disabled login method Check ~/.ssh/authorized_keys, user permissions, and your SSH config.

Dependency and runtime issues

Missing dependencies

Base packages or runtime packages were not installed Re-run the dependency step and compare runtime versions with official Claude Code docs.

Project runtime or npm install mismatch

The selected project or Claude Code npm install path expects a different runtime version Use the version manager or package source recommended by upstream docs.

Docker and process issues

Docker service not running

Docker daemon stopped or not installed Start Docker only if your project, dev container, or wrapper workflow actually requires it, then inspect the logs for that project-specific path.

Session stops after logout

Claude Code was started in a normal SSH shell Use tmux or screen for interactive continuity, or build a secured automation wrapper if you need non-interactive execution.

Project service port and firewall issues

Project service port already in use

A project dev server, tunnel, preview app, or wrapper service is bound to the same port Run ss -tulpn and move one service to a different port; Claude Code itself is normally a terminal workflow, not a listening web service.

Project service blocked by firewall

A required project, preview, tunnel, or wrapper port is not open Open only the required project-specific port and keep all other ports restricted.

Environment and API key issues

Missing configuration or credentials

Configuration is absent or incomplete Compare the generated configuration with the selected deployment path and add only the secrets and paths required.

Invalid API key or provider error

Key is wrong, expired, or lacks access Rotate the key through the provider and update the server configuration.

Disk and memory issues

Disk space issues

Logs, caches, or repositories grew over time Check df -h, rotate logs, clean caches, and scale storage if needed.

High memory usage

Too many build processes, test runners, package installs, or parallel coding sessions Reduce concurrency, inspect process memory, and scale the VPS if the workload is valid.

Ready to run Claude Code on an always-on VPS?

Deploy a Claude Code VPS and use this guide as your review checklist while you prepare the setup.

FAQ

Can I run Claude Code on a VPS?

Yes, if the Claude Code release supports the Linux distribution and runtime path you choose. Use this guide together with the current official documentation.

Do I need a GPU VPS for Claude Code?

Not for the VPS runtime pattern described here. This Claude Code guide focuses on terminal sessions, repositories, build tools, project logs, and account or provider access; verify separate hardware needs if you plan local model inference.

Does Virtarix provide API keys or model access?

No. Bring your own provider accounts, credentials, API keys, model access, repositories, and framework configuration.

What VPS size should I use for Claude Code?

Start Claude Code with the recommended Virtarix Cloud VPS S for a practical first deployment, then scale after measuring CPU, RAM, storage, and process count for Git repositories, terminal auth, build tools, and project-specific secrets.

Can Claude Code keep running without my local machine?

Yes for the remote workspace pattern: the VPS can keep repositories, terminal sessions, build tools, and project state available over SSH without your local machine staying online. Claude Code itself is normally started when you open or resume a terminal session, unless you build a separate secured automation wrapper.

Can I use Docker for this setup?

Use Docker when your project, dev container, or secured automation wrapper calls for it. Claude Code itself does not need to be presented as a Docker service for the normal terminal workflow.

Is Virtarix operating Claude Code for me?

No. Virtarix supplies self-managed VPS infrastructure. You install, configure, update, monitor, and secure Claude Code yourself.