Self-hosted environments are in public beta on Team and Enterprise plans and are off by default. See Availability and limitations for the enablement path and whatâs excluded.
claude --cloud, and scheduled routines, and by default they execute on Anthropicâs infrastructure. In a self-hosted environment, those same sessions execute inside your network, and the developer experience is otherwise the same apart from the differences in Availability and limitations and the deploy pageâs known issues.
If your team doesnât use cloud sessions, thereâs nothing here to configure: sessions in a terminal or IDE always run on the developerâs own machine. If you want to run Claude Code on your own always-on machine and drive it from other devices, use Remote Control, which is also available on Pro and Max plans. When youâre ready to set up, go straight to the quickstart; to review the security posture first, start with Deploy to production. The rest of this page explains how self-hosting works and when to choose it.
How self-hosted environments work
Self-hosting has three parts:- Environment: a named destination that cloud sessions can be sent to. Your organization creates environments in claude.ai admin settings, and each one groups a set of runners.
- Runner: a program running on hosts inside your network. Runners execute the sessions; the idea is the same as a self-hosted CI runner.
- Session: one Claude Code task a developer started.
api.anthropic.com, with the short list of further hosts sessions can reach in Network requirements. Anthropic never connects into your network.
Availability and limitations
Check these before planning a rollout:- Plans: public beta for Team and Enterprise organizations. Self-hosted environments are off by default; an Owner turns on Allow self-hosted environments on the Cloud environments admin page, which requires cloud sessions to be enabled for the organization.
- Zero Data Retention and HIPAA: unavailable for organizations with Zero Data Retention enabled or with the HIPAA configuration applied.
- Model inference: sessions use the Anthropic API unless you configure a runner to send model requests to Amazon Bedrock or Google Cloudâs Agent Platform. Session content goes to Anthropic in both cases. On a runner configured this way, server-managed settings and organization policies from claude.ai donât reach sessions.
- Surfaces: sessions started from claude.ai/code, the mobile and desktop apps, scheduled routines, and the terminal, with
claude --cloudor an--environmentdispatch, can run in self-hosted environments. Claude Tag sessions can run in them too, but Claude canât use Access bundles in those sessions yet. Claude Security and Code Review sessions donât route to them yet. Support for those two surfaces follows separately. - Repositories: sessions check out repositories from GitHub; see GitHub authentication options. For a GitHub Enterprise Server host, see its network requirements.
- Billing: sessions in a self-hosted environment consume your organizationâs Claude Code usage the same way sessions in Anthropic-hosted environments do.
Why self-host
Most teams are better served by Anthropic-hosted environments, which need no infrastructure to run or maintain. Self-hosting is for teams whose network, tooling, or compliance requirements call for keeping session execution on infrastructure they control. If thatâs you, plan for the operational ownership it carries: you build and maintain the runner image, operate the fleet, and control its network. In exchange, self-hosting gives you network access, custom tooling, and compliance control:- Network access: sessions run inside your network and can reach internal services, databases, and registries without exposing them to the public internet
- Custom tooling: pre-install compilers, SDKs, and internal CLIs in your runner image so every session starts ready to build
- Compliance: repository checkouts and build artifacts stay on infrastructure you control. Session content still goes to
api.anthropic.com.
Environments, runners, and sessions
Environments are managed on the Cloud environments page in claude.ai admin settings; runners are processes you start and manage on your own infrastructure.Key concepts
These terms appear throughout the self-hosted pages:
In API fields, token claims, and metric names, the environment appears as
pool, and the environment ID is the pool_id. The reference maps the two spellings, including the deprecated pool flag names.
A runner serves one owner at a time. The first session a runner picks up locks the runner to that sessionâs owner, and the runner then runs sessions only for that owner, up to a configured capacity. Who the owner is depends on how the session started:
- Sessions a user starts: the owner is that userâs account.
- Claude Tag channel sessions: Claude runs them with no user account attached, so the owner is the Claude Tag agent that started the session. Every channel session that agent starts has the same owner, whoever sent the Slack message, so a runner locked to it serves sessions that different people started when you run it at a
--capacityabove one or with a positive--drain-grace-sec.
Session lifecycle
When a developer starts a session and selects your environment, Anthropicâs control plane places the session on the environmentâs queue. From there:- A runner with free capacity claims the session and holds a lease on it.
- The runner clones the repository into its working directory and spawns a child Claude Code process.
- The child streams events back over HTTPS while the runner keeps polling; each poll refreshes the lease and doubles as the heartbeat.
- If the runner stops polling, its lease lapses after about 60 seconds, and the server requeues the session for another runner within a few minutes.
Runner lifecycle
The first session a runner picks up locks the runner to that sessionâs owner, and the runner runs up to--capacity concurrent sessions for that owner. While the runner has active sessions and hasnât received a shutdown signal or reached its retire time, the runner keeps claiming the locked ownerâs queued work. What happens once they finish depends on --drain-grace-sec:
- At the default of
0: the runner exits as soon as its active sessions finish, without polling for more, so the orchestrator you deploy it under, such as Kubernetes, can restart it with a fresh disk, ready to serve any owner. - At a positive value: the runner keeps polling the locked ownerâs queue for that many seconds before exiting.
--retire-at. A kill that delivers SIGTERM needs no flag: the runner drains as Shutdown timing describes, or keeps serving the sessions it already holds when you set --defer-shutdown-max-min. If your infrastructure instead destroys hosts at a known wall-clock time without a signal, or with a grace period too short to drain, such as a sandbox lifetime cap or spot-instance reclamation, pass --retire-at <epoch-seconds> set to a few minutes before that time. At the retire time:
- The runner stops taking new work.
- The runner releases each active session through the same release path the
--release-idle-session-minflag uses, so the session resumes on a fresh runner when the user sends their next message. When the runner releases each session depends on its state:- The runner releases a session thatâs mid-turn after that turn finishes. It first waits for the sessionâs process to report the turnâs end to Anthropic, for no longer than
SELF_HOSTED_RUNNER_POST_TURN_SETTLE_MS. Before v2.1.280, the runner released the session as soon as the turn finished. - When a turn finishes and leaves background tasks running, the runner waits up to 60 seconds for them, then releases the session even if theyâre still running. If the tasks have finished but the follow-up turn that reads their results hasnât run yet, the runner keeps the session until that turn finishes, and waits no longer than
SELF_HOSTED_RUNNER_BG_RESULT_GRACE_MSfor that turn to start.
- The runner releases a session thatâs mid-turn after that turn finishes. It first waits for the sessionâs process to report the turnâs end to Anthropic, for no longer than
- The runner exits 0 once all its sessions are released.
--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 to another runner.
Network paths
The runner and its sessions make several kinds of outbound connection, and no inbound connectivity from Anthropic is required:- Control plane: the runner polls
api.anthropic.comfor work and posts setup-progress and failure events, all outbound HTTPS. Polling doubles as the runnerâs heartbeat. - SCM connector: the optional orchestrator SCM connector tunnel is the only WebSocket connection.
- Git: the runner clones from and pushes to your git host over HTTPS or SSH, authenticated with credentials your deployment provides; Configure git covers the options, including per-session minted credentials and the Anthropic git proxy, which routes git through
api.anthropic.cominstead. - Session child: the child Claude Code process holds the sessionâs event stream to
api.anthropic.com, and makes its own outbound calls for model inference and for git commands run during the session. See Network requirements for the full egress list. The diagram above shows these paths, apart from the optional SCM connector.
HTTPS_PROXY and NO_PROXY; set them in each processâs environment. The variables cover control-plane calls, the orchestratorâs SCM connector WebSocket, and the built-in clone for HTTPS remotes, and sessions inherit them from the runner. Session streaming uses server-sent events over HTTPS, so a proxy in the path must not buffer responses.
If your proxy also requires a Proxy-Authorization header, the runner can add it to each connection it opens to the proxy; see Authenticate to an egress proxy.
What stays on your infrastructure
Repository checkouts, build artifacts, secrets, and any files a session creates or modifies stay on the machines you provision. The conversation itself, including prompts, responses, and tool results, goes toapi.anthropic.com, and Anthropic stores the session transcript so you can resume the session from another supported surface. When a runner sends model requests to Amazon Bedrock or Google Cloudâs Agent Platform, the conversation still goes to api.anthropic.com in the sessionâs event stream.
A self-hosted environment moves session execution into your network. The control plane remains Anthropic-hosted: session orchestration, queueing, and the claude.ai interface continue to run on Anthropicâs infrastructure.
Get started
The self-hosted environments pages are organized by what youâre doing:- Quickstart: install Claude Code, create an environment, start a runner, and route your first session
- Deploy to production: security hardening, network egress, git credentials, Kubernetes and Compose recipes, known issues, and troubleshooting
- Customize sessions: wrapper scripts for per-session credentials, lifecycle hooks, on-demand runners, MCP servers, and permissions
- Test end to end: a CI smoke test that verifies a runner image before you promote it
- Reference: every CLI flag, environment variable, metric, and the health endpoint
- Verify session identity: validate the session token from your own services before granting access