How to host Claude Code on a persistent VPS
read · 6 min
Claude Code is an API-based agent: it needs no GPU, just Node.js and an Anthropic API key. Put it on a VPS and your coding agent keeps running long after you close your laptop.
Steps
Connect to your VPS
Provision an unmanaged Linux VPS and connect over SSH. A clean Ubuntu or Debian image is enough — Claude Code is light on resources.
$ ssh root@your-server-ip Install Node.js 22
Claude Code runs on Node.js. Install the current LTS from NodeSource.
$ curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
$ sudo apt-get install -y nodejs
$ node --version Install the Claude Code CLI
Install the CLI globally with npm.
$ npm install -g @anthropic-ai/claude-code
$ claude --version Set your API key
Export your Anthropic API key and persist it so every shell session has it.
$ echo 'export ANTHROPIC_API_KEY="sk-ant-..."' >> ~/.bashrc
$ source ~/.bashrc Run inside a persistent tmux session
Start Claude Code inside tmux so it survives a dropped SSH connection. Detach with Ctrl+B then D, and reattach any time.
$ tmux new -s claude
$ cd ~/projects/my-repo
$ claude
# detach: Ctrl+B, then D
$ tmux attach -t claude Frequently asked
Do I need a GPU to run Claude Code? +
No. Claude Code calls the Anthropic API, so all inference happens on Anthropic’s side. The VPS only needs CPU, RAM and Node.js.
How much RAM does the VPS need? +
Claude Code itself is light — 2 GB RAM is comfortable. Size the VPS for your project’s build and test tooling, not for the agent.
Can it really run 24/7? +
Yes. Inside tmux (or a systemd service) the session persists across disconnects and reboots, so the agent keeps working while you are away.
Related guides
Need a server to run it on?
Pick a VPS with full root access in a secure Estonian data center.
See VPS plans →