Claude Code Self-Hosted Runners: Cloud Sessions, Your Box

It is a named destination that Claude Code cloud sessions can be routed to, executing on runners you deploy inside your own network. A runner claims a queued session, clones the repository, and spawns a Claude Code child process on your host. Repository checkouts and build artifacts stay on machines you provision.
No. Every connection is outbound: the runner polls api.anthropic.com for work, clones from your git host, and each session child holds its own outbound event stream and inference calls. Anthropic never connects into your network, which makes the network review considerably simpler than a self-hosted CI runner needing a webhook endpoint.
At minimum, one per user you expect to be active at once. A runner serves one user at a time — the first session it claims locks it to that account, so checked-out code never mixes between users — and it then runs up to its configured capacity of concurrent sessions for that one account.
No. Sessions use the Anthropic API, and inference cannot be routed through Amazon Bedrock, Google Cloud's Agent Platform, Microsoft Foundry or an LLM gateway. Self-hosting moves session execution into your network; it does not move model inference onto your cloud provider. Those are separate concerns.
No. Self-hosted environments are unavailable for organisations with Zero Data Retention enabled. They are also a public beta limited to Team and Enterprise plans, off by default until an Owner enables them on the cloud environments admin page, which itself requires Claude Code on the web to be enabled.

Key Takeaway
A Claude Code self-hosted environment runs cloud sessions on infrastructure your organisation operates. Runners poll the Anthropic control plane, claim sessions, clone the repository and spawn a Claude Code child process on your host. Every connection is outbound; Anthropic never connects into your network. Repository checkouts and build artifacts stay on your machines.
The objection I hear most often to cloud coding sessions is not about the model. It is that the repository has to leave the building, and for a lot of teams that ends the conversation before it starts. Self-hosted environments are the answer to that specific objection, and the shape of the answer is worth understanding precisely, because it solves less than people hope and more than they expect.
This post covers the three-part architecture, the network paths that make it a genuine security story, the runner lifecycle rule that determines your fleet size, and the exclusion list that decides whether you can use it at all — which is the section to read first, because several of the exclusions are dealbreakers.
The vocabulary matters here because the docs use it consistently and the concepts do not map onto CI intuitions cleanly:
When a developer starts a cloud session, the picker lists Anthropic-hosted environments alongside yours. Choose yours and the control plane places the session on your environment's queue, where a runner claims it, clones the repository, and starts the work. The control plane stays Anthropic-hosted throughout — session orchestration, queueing and the claude.ai interface are not things you are self-hosting.
This is the part that makes the security review straightforward. The runner and its sessions make several kinds of outbound connection and require no inbound connectivity at all. That is a materially easier conversation than a self-hosted CI runner that needs a webhook endpoint, and it is worth leading with when you take this to a network team.
# Every connection is OUTBOUND. Anthropic never connects
# into your network — there is no inbound port to open.
your network
├─ runner ──────────► api.anthropic.com (poll queue, post events)
│ the poll IS the heartbeat
├─ runner ──────────► your git host (clone / push, HTTPS or SSH)
├─ session child ───► api.anthropic.com (event stream + inference)
└─ session child ───► your internal services, databases, registries
# Corporate egress proxies are supported: the runner and the
# autoscaling orchestrator honour HTTPS_PROXY and NO_PROXY, and
# sessions inherit them. Session streaming is server-sent events
# over HTTPS, so a proxy in the path MUST NOT buffer responses.The optional SCM connector tunnel used by the autoscaling orchestrator is the only WebSocket connection in the whole design. If your egress policy treats WebSockets differently from ordinary HTTPS — and plenty do — that is the one exception to plan for, and you can skip it entirely by running long-lived runners instead of on-demand ones.
This is the rule that decides your capacity planning, and it is not obvious from the outside. A runner serves one user at a time: the first session it claims locks it to that user's account, and it then runs only that account's sessions up to its configured capacity. The purpose is isolation — checked-out code never mixes between users, without the runner having to scrub disk state between them.
# A runner serves ONE USER AT A TIME. The first session it
# claims locks it to that user's account, so checked-out code
# never mixes between users. That single rule sets your fleet
# size: minimum runners = users active at once.
--capacity <N> # concurrent sessions for the locked account
--drain-grace-sec 0 # DEFAULT: exit as soon as active sessions
# finish, so your orchestrator restarts it
# with a fresh disk, ready for any account
--drain-grace-sec 300 # keep polling the locked account for 5 min
--retire-at <epoch-secs> # for hosts destroyed at a known wall-clock
# time with NO signal — spot reclamation, a
# sandbox lifetime cap. Set it a few minutes
# before the kill.
# Without --retire-at, a signal-less host kill is indistinguishable
# from a crash: the control plane records a lost worker rather than
# a clean release, and the session requeues elsewhere.The consequence is that your minimum fleet size is the number of users you expect to be active at once, not the number of concurrent sessions. Five developers each running one session need five runners; one developer running five sessions needs one runner with a capacity of five. Getting this backwards is the fastest way to under-provision a pilot and conclude the feature is slow.
Knowing the lease mechanics turns most runner debugging into arithmetic:
Being precise here is the difference between a security review that passes and one that stalls. The boundary is real but it is not total, and overselling it is the fastest way to lose credibility with a reviewer who reads the docs.
Where each thing actually lives:
| What | Where it stays | Note |
|---|---|---|
| Repository checkouts, build artifacts, secrets | Your machines only | Any file a session creates or modifies stays on hosts you provision |
| Prompts, responses, tool results | Sent to the Anthropic API | Required for model inference; the transcript is stored so sessions resume elsewhere |
| Session orchestration and queueing | Anthropic's control plane | Not something self-hosting moves |
Read this list first. Several entries are hard stops, and one of them rules out a whole class of enterprise deployment:
The inference exclusion is the one that catches enterprise teams. Self-hosting moves session execution into your network; it does not move model inference onto your cloud provider. Those are separate concerns solved by separate features, and a team that adopts self-hosted environments expecting Bedrock inference will discover the mismatch after building the runner image, not before.
Most teams are better served by Anthropic-hosted environments, which need no infrastructure to run or maintain. Self-hosting means you build and maintain the runner image, operate the fleet, and control its network — real, permanent operational ownership in exchange for three things: sessions that reach internal services without exposing them publicly, a runner image with your compilers and internal CLIs pre-installed, and checkouts that stay on machines you control.
If your team does not use cloud sessions at all, there is nothing here to configure — terminal and IDE sessions always run on the developer's own machine. And if what you actually want is to run Claude Code on your own always-on box and drive it from other devices, that is Remote Control, which is available on Pro and Max too and needs none of this.
How your infrastructure stops a runner decides whether you need the retire flag. A kill that delivers a termination signal needs nothing extra — the runner drains on its own. But a host destroyed at a known wall-clock time without a signal, such as spot reclamation or a sandbox lifetime cap, is indistinguishable from a crash: the control plane records a lost worker rather than a clean release. Set the retire time a few minutes before the kill and sessions release cleanly instead.
Self-hosted environments are a well-shaped answer to a narrow question: can cloud sessions run where our code already lives. They answer it convincingly, with an all-outbound network model that survives a security review. They do not answer where inference happens, they do not work under Zero Data Retention, and they carry the ongoing cost of a fleet you now operate. Decide whether the narrow question is the one you actually have before building anything.
Sources & further reading