Where to Self-Host Claude Code

Self-host Claude Code on a Mac mini, Linux VPS, or container host you administer when you need control over the agent process and workspace. Choose the host whose storage, network access, and rebuild procedure you can verify against your requirements.

Decide which process you must control

Start by writing down where the repository, agent loop, and model inference are allowed to run. For an application built on Claude Code, Anthropic documents self-hosting the Agent SDK, which supervises a Claude CLI subprocess on your infrastructure. Provision the host, give the worker a dedicated working directory, and use a test repository to identify where the subprocess runs and where its session files land.

A Mac mini is a candidate when a build needs macOS or a tool available on that machine. A Linux VPS is a candidate when the build runs on Linux and an operator can administer the server remotely. Docker on your own cloud is a packaging choice for that Linux workload. Decide separately who operates the host, where the writable state lives, and which model endpoint the worker may contact.

Measure the worker from the operating system where it will actually run. Idle usage includes resident services that would otherwise be omitted from a household or hosted machine comparison.

Hosting the Agent SDK - Claude Code Docs

Test the network from the worker

Hetzner Cloud documents private networking and stateful firewalls for its VPS infrastructure. A Linux VPS is worth testing if you can put the required services on a network the worker can reach and your team can operate the host. Run the checks from the same account and environment that will execute Claude Code, since an administrator’s laptop may have different routes and credentials.

In an illustrative case, assume a Linux build needs a private package registry, your team permits its Anthropic endpoint, and an operator can rebuild the server. Start with a test repository and a read-only registry credential. Pass the trial when the worker can install dependencies, run the tests, and write an artifact while an unapproved ingress probe from your own test machine is blocked. If installation fails, check routing and credential scope before expanding access.

Leave room for exit handling, background work and monitoring. Treat the calculated worker count as a limit to test, then measure the complete workload at that concurrency.

Cloud-hosting provider for developers & teams

Make a rebuild the acceptance test

When you package the Claude Agent SDK in Docker or replace a VPS, test what happens to session history. The SDK writes transcripts to the local filesystem by default. For recovery across hosts, configure an external SessionStore and preserve a matching working directory for resume. Keep a separate backup of any workspace changes you need to recover, and record the revision and configuration used to create the worker.

Before approving the deployment, build a fresh worker from the same configuration and attempt to resume a disposable job. If command execution works but the session cannot be found, compare the working directory and confirm that the transcript made it into the external store. If you only need repeatable jobs that start fresh, compare the cost of restoring sessions with the simpler option of rerunning from a known commit.

Persist sessions to external storage - Claude Code Docs

Sources