OmniscioGuidesSelf-hosted runner setup
Claude Code self-hosted runner setup
Self-hosted environments are in public beta on Team and Enterprise plans. Your network runs the session; Anthropic keeps the control plane that hands the work out.
Last checked against Anthropic's documentation on November 27, 2026. By the Omniscio team. Updated .
What you are setting up
A self-hosted environment runs Claude Code cloud sessions on infrastructure your organization operates, executed by runner processes you deploy. For a first test you need the smallest setup: one runner on a single host, running one session.
You work on two surfaces. claude.ai creates the environment, shows its status and routes a session; the runner itself runs in a terminal on the host.
What stays inside your network, what does not, and the runner lifecycle are on the self-hosted environments guide.
Before you start
- An Owner turns it on. On the Cloud environments page in admin settings, the New button does not appear until Allow self-hosted environments is on.
- The GitHub connector. An Owner turns it on, and each developer connects their own GitHub account, so repositories can be picked when a session starts.
- Network. Outbound HTTPS to
api.anthropic.com, toclaude.aiand the download hosts it redirects to, and to your git host for the clone. - A test repository. A public one, or one the host can already clone by its HTTPS URL without being asked for credentials. An SSH key alone is not enough, because the runner clones the
https://URL. - Software. Claude Code v2.1.224 or later, Git 2.24 or newer, and a clock kept in sync, for example with NTP. A runner that also serves Claude Tag sessions, the ones started from Claude Tag, needs v2.1.229 or later and
python3on itsPATH.
Confirm the host is ready before anything else:
claude self-hosted-runner --helpA ready host prints the runner's usage text, including flags such as --environment-secret-file. On a version older than 2.1.224 the command prints the general claude --help output instead, which means the version is the problem.
Option one: the guided setup
Run this in your shell, on a machine where you are signed in with claude auth login using an account that holds an Owner role:
claude self-hosted-runner setupIt starts an interactive Claude Code session that walks you through creating the environment, starts a local runner with the secret file you save, confirms that the runner registers, and writes a cheat sheet to ./runner-setup/CHEAT-SHEET.md.
The setup saves the environment secret for you, in the file the cheat sheet names. Two limits worth knowing: it does not start a test session itself, and its last step stops the runner it started. Start the runner again from the cheat sheet's command, then start a session at claude.ai/code and pick your environment and repository in the picker, as manual step 4 below describes.
Option two: the manual steps
Use these on a host where an interactive session is not possible, or when an Owner already created the environment and handed you its secret. In that case start at step 2.
1. Create the environment
On the Cloud environments page in admin settings, under Self-hosted environments, select New, name the environment and select Create. On the wizard's second step, select Copy environment key. claude.ai shows the secret once, and it expires 365 days after creation.
2. Save the secret to a file
These commands read the secret from your terminal, so it stays out of shell history. The umask makes the file readable only by its owner. Replace <dir-you-own> with a directory the runner's user can write to; /etc/claude is the usual choice when the runner runs as root:
mkdir -p '<dir-you-own>'
(umask 077 && cat > '<dir-you-own>/environment-secret')Paste the key, press Enter, then Ctrl-D. Pass the same path to --environment-secret-file. A path the runner cannot read exits with Failed to read environment secret file and a permission error.
3. Start the runner
Choose an absolute base directory the runner can write to. Use a directory dedicated to the runner, not your home folder or a directory of your own clones, because the runner treats <base-dir>/<repo-owner>/<repo> as its own and can reset it:
claude self-hosted-runner --environment-secret-file '/etc/claude/environment-secret' --base-dir '<writable-dir>'The runner logs Registered: runner_id=<runner-id> once it registers, then polls for work. Without --base-dir it uses /workspace, which works only if that directory already exists and is writable or you start the runner as root.
4. Confirm and route a session
Back on the Cloud environments page, the status changes from No runners deployed to Healthy within a few seconds, and Activity lists the runner. Start a session at claude.ai/code, choose your environment in the picker, and pick the test repository.
The runner logs Picked up session <session-id> with its active count and capacity, so you can confirm from the host which machine took it.
How to message the running session
A finished turn does not end the session. From the claude CLI on any machine where you are signed in, send one message:
claude -p "your message" --cloud <session-id>Pass the bare session_... or cse_... ID, or the session's claude.ai/code URL. A successful send prints Sent to cloud session. with the session ID and a view link.
When the runner exits
The runner runs in the foreground: keep that terminal open, because closing it stops the runner. Started with the plain runner command, it exits after serving one session, not after each turn, and a lost connection can end it too. If it exits during this setup, start it again.
[runner:exit] account workload drained — exiting: it is no longer running a session. That is by design; start it again for the next one.[runner:fatal]withrunner record gone server-side: the runner or its environment was removed or recreated on Anthropic's side. Check the environment on the Cloud environments page, then start the runner again.[runner:fatal]withpoll auth failed: the runner could not authenticate, which is what a revoked environment secret looks like. Roll the new secret out to the runner and start it again.- A run that loses contact with Anthropic for a while, for example a host that slept, can exit when it next reaches Anthropic. Start it again.
For production, run the runner under an orchestrator that restarts it on exit and waits longer between restarts when it keeps exiting right after starting. Anthropic's deployment page covers the hardening, egress control and git credentials.
Common mistakes
- Using an SSH-only checkout. The runner clones the repository's
https://URL and is never prompted for credentials. An SSH key alone does not work. - Choosing your home folder as the base directory. The runner can reset and overwrite what it finds under its base directory. Give it a dedicated path.
- Expecting it to keep serving sessions. The plain command exits when nothing is running. Restart it, or use an orchestrator.
- Storing the environment key in shell history. Write it to a file that only its owner can read; claude.ai shows it only once.
- Trying a Windows host. Windows is not supported as a runner host; run the runner in a Linux container instead. Developer workstations are unaffected.
Where these answers come from
- Anthropic's self-hosted environments quickstart, read November 27, 2026: the prerequisites, the guided setup, every manual command, the routing steps, the follow-up command, and the exit cases.
- Anthropic's self-hosted environments page, read November 27, 2026: the public beta on Team and Enterprise, and the runner lifecycle.
- Anthropic's deployment page, read November 27, 2026: the orchestrator advice and the production prerequisites the quickstart points to.
Common questions
What is a self-hosted runner in Claude Code?
It is the process that runs Claude Code cloud sessions on infrastructure your organization operates. You create an environment on claude.ai, start a runner on a Linux or macOS host, and sessions you route to that environment run on that host.
Which host and software does the runner need?
A Linux or macOS host or container, not Windows, with outbound HTTPS to api.anthropic.com, claude.ai and its download hosts, and your git host. It needs Claude Code v2.1.224 or later, Git 2.24 or newer, and a clock kept in sync.
Why does the runner exit after one session?
That is by design. Started with the plain runner command, it exits once it is no longer running a session, and the log says account workload drained. Start it again for the next session, or run it under an orchestrator that restarts it in production.
How do I send a follow-up message to the session?
Run claude -p with your message and the --cloud flag naming the session, from any machine where you are signed in. A successful send prints Sent to cloud session with the session ID and a view link.