Claude Code is an Anthropic programming agent that runs in the terminal and requires persistent access to the system, control of the environment, and dedicated resources that shared hosting cannot offer. A VPS server is the right solution for stable and secure deployment.
What is Claude Code and how does it work?
Claude Code is an AI-assisted programming tool developed by Anthropic. Unlike AI assistants that run on a web interface, Claude Code runs directly on the operating system terminal. This means it can read files, edit code, execute commands, and navigate the structure of a real project autonomously and continuously.
The difference with other similar tools is important: Claude Code is not just a chatbot with access to code. It is an agent that interacts with the file system, manages processes, and can chain complex tasks during extended sessions.
For all of this to work, the execution environment must meet very specific requirements. And that’s where the type of hosting makes a real difference.
Why Claude Code does not work on shared hosting
Shared hosting places hundreds of websites on the same physical server. Each account has restricted access to a portion of resources: CPU, RAM, simultaneous connections, and, above all, system permissions.
In practice, this creates specific problems when trying to run Claude Code: Simply put, shared hosting is designed to serve web pages, not to run software agents with access to the operating system. They are tools for different purposes.
No real SSH access: Shared hosting may offer a limited terminal, but it rarely allows you to run persistent processes or install system dependencies at the root level.
What Claude Code needs to run properly
When setting up an environment for Claude Code, the minimum requirements that need to be met are: All of this accurately describes the profile of a well-configured VPS server.
Full SSH access to the server to install dependencies, configure environment variables, and run background processes.
Updated Node.js (version 18 or higher recommended), as the Claude Code CLI is published as an npm package.
Sufficient RAM: at least 2 GB is recommended for medium-sized projects. For large projects with many files in context, 4 GB is more appropriate.
Persistent processes: tools such as screen, tmux, or a process manager such as PM2 allow Claude Code to remain active even if the SSH session is closed.
SSD storage: the agent constantly reads and writes files during execution. A slow disk directly affects its performance.
Stable internet connection: Claude Code communicates with the Anthropic API to process each instruction. High latency or intermittent connections generate chain errors.
For projects that require full server control and dedicated resources, Neolo’s VPS hosting offers full root access, NVMe disks, and the ability to choose the server region closest to users. It is a solid option for those who work with tools such as Claude Code that demand a controlled and stable environment.
How to configure a VPS for Claude Code step by step
The following describes the configuration process on a VPS with Ubuntu 22.04 LTS, which is one of the most common and compatible operating systems.
1. Connect to the server via SSH
1
ssh user@server-ip
2. Update the system
1
sudo apt update && sudo apt upgrade -y
3. Install Node.js (version 20 LTS)
123
curl -fsSLhttps://deb.nodesource.com/setup_20.x| sudo -E bash -
sudo apt install -y nodejs
node -v # Check the installed version
4. Install Claude Code CLI
1
npm install -g @anthropic-ai/claude-code
5. Configure the Anthropic API key
1
export ANTHROPIC_API_KEY="your-key-here"
To make the variable persist between sessions, add it to the profile file:
12
echo ‘export ANTHROPIC_API_KEY="your-key-here"’ >> ~/.bashrc
source ~/.bashrc
6. Install tmux to keep sessions active
1234
sudo apt install -y tmux
tmux new -s claude
# Inside tmux, run Claude Code
claude
To disconnect without closing the session: Ctrl+B, then D. To return to the session: tmux attach -t claude.
7. Verify that everything is working
1
claude --version
If the command responds with the version number, the environment is ready.
This process is standard, but in practice there are variations depending on the operating system distribution and VPS configuration. If you are working with Ubuntu 24.04 or Debian 12, the Node.js installation commands may differ slightly in the official NodeSource repository URL.
Common errors when trying to run Claude Code without a VPS
Trying to run it from cPanel or Plesk
Some users try to open a terminal from their shared hosting control panel. The result is always the same: insufficient permissions to install npm packages globally, and processes that shut down after a few minutes.
Not setting the environment variable correctly
If ANTHROPIC_API_KEY is not defined in the runtime environment, Claude Code will throw an authentication error. A common mistake is to define it only in the current session without persisting it in .bashrc or .profile.
Using old versions of Node.js
The Claude Code CLI requires modern JavaScript features. Node.js 14 or earlier versions generate compatibility errors that are not always clear in the error message.
Not using tmux or screen
Without a terminal multiplexer, Claude Code stops when the SSH connection is closed. Many users notice that processes they “left running” were actually interrupted when their SSH client closed the session due to inactivity.
Choosing a VPS with low RAM
A VPS with 512 MB of RAM may seem sufficient to start with, but in projects with many files in context, the operating system itself (along with basic services) consumes between 200 and 400 MB, leaving very little room for the agent.
Little-known tips for optimizing Claude Code on a VPS
Use PM2 instead of tmux for long-running projects. PM2 is a process manager for Node.js that can automatically restart Claude Code if the process fails, log records, and keep the agent active after server restarts.
1234
npm install -g pm2
pm2 start “claude” --name claude-agent
pm2 save
pm2 startup
Limit the project context. Claude Code has a limit on the context it can process in each session. Including irrelevant files (such as node_modules or cache folders) slows down the agent and can cause errors. Using a .claudeignore file with the same format as .gitignore solves this problem.
Place the server in the region closest to the Anthropic API. Anthropic’s servers are mainly in the United States. If the VPS is in Latin America or Europe, the latency of each API call adds a few milliseconds. In long sessions, this difference accumulates. Choosing a VPS in a data center in the United States can significantly reduce response time.
Monitor RAM usage during execution. The htop command allows you to see in real time how much memory the Claude Code process is consuming. If the system reaches 90% RAM, performance degrades rapidly. It is best to scale up the plan before a problem occurs.
Configure a .env file with dotenv. Instead of exporting variables directly in .bashrc, using a .env file in the project directory and loading it with dotenv allows you to manage multiple projects with different API keys without conflicts.
Managing a VPS also involves taking security measures from day one. Security tips for protecting a VPS from attacks cover essential aspects such as SSH configuration, firewall, and automatic updates.
Frequently asked questions
Can Claude Code run on a dedicated server instead of a VPS?
Yes, and with better results. A dedicated server offers exclusive resources that eliminate any shared performance issues. It is the most suitable option for development teams that use Claude Code intensively or for multiple simultaneous projects. For individual use or small teams, a well-configured VPS is more than sufficient.
Which operating system is best for running Claude Code on a VPS?
Ubuntu 22.04 LTS or Debian 12 are the most recommended options due to their compatibility with Node.js, extensive documentation, and long-term stability. CentOS 7 no longer receives security updates and is not a suitable option for production environments.
Does Claude Code consume a lot of server resources while idle?
When Claude Code is not processing any instructions, its CPU consumption is minimal. Most of the processing occurs during the execution of each task. RAM does remain in use while the process is active, regardless of whether it is processing or waiting for instructions.
Is it safe to store the Anthropic API key on the server?
Yes, as long as basic precautions are taken: store it in environment variables (never directly in the source code), restrict SSH access to the server using public keys, and ensure that the .env file is not included in any git repository. Enabling two-factor authentication for access to the VPS panel adds an additional layer of security.What size VPS is recommended to get started with Claude Code?
What size VPS is recommended to get started with Claude Code?
For small projects or personal use, a VPS with 2 CPUs and 2 GB of RAM is a reasonable starting point. For projects with large repositories, multiple users, or integrations with other tools (such as n8n or databases), 4 GB of RAM is more appropriate. It is always best to start with a plan that has the possibility to scale vertically.
Can Claude Code run alongside other applications on the same VPS?
Yes. It is perfectly possible to run Claude Code on the same VPS that also hosts a web application, database, or automation tool. The important thing is to monitor resource usage to ensure that no process affects the performance of others.
Is there an alternative to using your own VPS to run Claude Code?
Anthropic offers Claude.ai and integrations through its API, but running the Claude Code agent with access to the file system necessarily requires a local environment or a server that the user controls. There is currently no cloud-hosted alternative from Anthropic that replicates the behavior of the CLI with full access to the system.
Conclusion
Claude Code is a powerful tool for developers and teams who want to integrate real AI into their workflow. But its architecture, based on direct access to the operating system, requires an environment that shared hosting simply cannot provide.
A well-configured VPS server meets all requirements: SSH access, environment control, persistent processes, and dedicated resources. Initial setup takes less than an hour, and once up and running, the agent works stably and predictably.
Neolo has been in the market for over 20 years and operates as a bootstrapped company, funded by its own customers and without external investors.
That translates into decisions geared toward actual service, not growth metrics. If you’re looking for a stable server base to run Claude Code or any other development tool that needs full control of the environment, Neolo’s VPS hosting includes full root access, human technical support, and a 30-day money-back guarantee if the service doesn’t meet your needs.
