How to set up self-hosted GitHub Actions runners
Set up a self-hosted GitHub Actions runner step by step: register, run as a service, go ephemeral, keep it updated, and choose an autoscaler.
In this series24 guides, you're on Self-hosted runners
A self-hosted runner is a machine you own (a VM, a cloud instance, a server, a Mac mini) running GitHub’s open-source runner application ↗. It connects out to GitHub, waits for jobs, and runs them. You pick the hardware, the network it sits in and the software installed on it, and you pay your cloud provider instead of GitHub’s per-minute rates.
Self-hosting is worth it when you need hardware or network access that GitHub’s runners don’t offer, when you run enough minutes that your own compute costs less than GitHub’s rates, or when code and secrets must stay on machines you control. It isn’t worth it when your usage is light or when nobody wants to patch, scale and secure runners. Should you self-host? compares the options side by side.
This guide sets up a runner by hand, then covers what changes when you need many of them.
Before you start#
- Who can register: a repository admin for a repository runner, an organization owner (or someone with the “Manage organization runners and runner groups” permission) for an organization runner.
- The machine needs outbound HTTPS (port 443) to
github.comand the Actions service domains (no inbound ports), and a supported OS ↗: Linux (x64 or arm64; 32-bit Arm is no longer supported), Windows or macOS. - Filtered egress: if a firewall or proxy limits outbound traffic, allow the domains that GitHub’s meta API ↗ lists under
domains.actions_inbound. Itswildcard_domainslist rarely changes. If you allow the exact names infull_domainsinstead, check that list weekly: GitHub adds a domain to the meta API at least a week before it goes into use. GitHub’s docs also group the domains by function ↗. - Software: installing the runner adds only the runner application, none of the tools preinstalled on GitHub’s runner images, so install what your jobs use. Jobs with
container:,services:or Docker container actions need a Linux runner with Docker installed, and the runner’s user needs access to the Docker socket. - Public repositories: GitHub advises against self-hosted runners on them, because anyone can open a pull request whose workflow runs on your machine. Even an ephemeral runner gives that code your network and any cloud role the machine has. Use GitHub-hosted runners for public code. If you must self-host, use ephemeral runners in a separate cloud account or network, with no credentials on the machine, and set fork pull request approval to Require approval for all external contributors.
1. Register the runner#
In the repository, go to Settings → Actions → Runners → New self-hosted runner (in an organization: Settings → Actions → Runners → New runner → New self-hosted runner), pick the OS and architecture, and GitHub shows the exact commands with a short-lived registration token. On Linux x64 they look like this:
mkdir actions-runner && cd actions-runnercurl -o actions-runner.tar.gz -L \ https://github.com/actions/runner/releases/download/v2.338.2/actions-runner-linux-x64-2.338.2.tar.gzecho "<SHA256> actions-runner.tar.gz" | sha256sum -ctar xzf actions-runner.tar.gz
./config.sh \ --url https://github.com/my-org/my-repo \ --token <REGISTRATION_TOKEN> \ --name build-01 \ --labels gpu,large \ --unattendedUse the version GitHub’s page shows (the releases ↗ list the latest). Each release also lists the SHA-256 checksum of each runner package: put the one for yours in place of <SHA256>, and extract the archive only if sha256sum prints OK. The runner registers with the default labels self-hosted, linux and x64, plus the custom ones you pass with --labels.
2. Run it as a service#
./run.sh starts the runner in the foreground, which is fine for a test. For a machine that should survive reboots, install it as a service:
sudo ./svc.sh install # Linux: creates a systemd unitsudo ./svc.sh startsudo ./svc.sh statusOn Linux, svc.sh install without a user name runs the service as the account that ran sudo, usually your admin account. To use a dedicated account, create it (sudo useradd -m runner) and give it a directory that your admin account can also open (sudo mkdir /opt/actions-runner && sudo chown runner: /opt/actions-runner). In that directory, run step 1’s curl, tar and ./config.sh commands with sudo -u runner in front (config.sh refuses to run as root; add --replace if a runner with that name is already registered). Then, from your admin account and in the same directory, run sudo ./svc.sh install runner: the service runs as runner, from the directory you install it in.
On macOS, run the svc.sh commands from the block above without sudo: there svc.sh refuses to run as root, and it installs a LaunchAgent for the current user. After a reboot, a LaunchAgent starts only when its user logs in, so turn on automatic login for that user if the Mac has to come back on its own.
On Windows, run config.cmd from an administrator shell and answer Y when it asks whether to run the runner as a service. With --unattended it doesn’t ask, so add --runasservice. The runner should now show as Idle in the settings page.
3. Send a job to it#
jobs: build: runs-on: [self-hosted, linux, x64, large] steps: - uses: actions/checkout@v7 - run: ./build.shThe runs-on guide explains how these labels pick a runner, and covers runner groups and dynamic labels.
If a job doesn’t start or doesn’t finish:
-
It stays queued. No matching runner is online and idle, or the repository isn’t allowed to use the ones that are: Things that go wrong lists the usual causes. After 24 hours in the queue, the job fails.
-
It stops halfway on Ubuntu or Debian.
needrestart, which restarts services after package upgrades, can restart the runner service in the middle of a job. This command tells it to leave the runner alone:echo '$nrconf{override_rc}{qr(^actions\.runner\..+\.service$)} = 0;' | sudo tee /etc/needrestart/conf.d/actions_runner_services.conf -
The runner is gone from the settings page. GitHub removes a runner that hasn’t connected for 14 days (1 day for an ephemeral runner), and you have to register it again.
4. Prefer ephemeral runners#
A runner that stays up between jobs keeps whatever the last job left behind: files in the workspace, Docker images, credentials in ~/.docker/config.json, a process someone started in the background. That makes builds flaky, and it lets one malicious job tamper with the next one.
Register with --ephemeral and the runner takes one job, then unregisters itself:
./config.sh --url https://github.com/my-org --token <TOKEN> --ephemeral --unattended./run.shYou then need something that creates a fresh machine (or container) for every job, which is what autoscalers do. GitHub recommends ephemeral runners for any autoscaling setup: with persistent runners it can’t guarantee a job won’t be sent to a runner that’s shutting down. For automation, the REST API can also create just-in-time runner configurations (generate-jitconfig), which skip the registration-token step entirely.
If you keep a persistent runner, give it a cleanup script ↗ that runs before every job: set ACTIONS_RUNNER_HOOK_JOB_STARTED to the script’s absolute path in the runner’s .env file, and restart the runner. It reduces leftover state, but it isn’t a security boundary: it runs as the same user as the jobs.
5. Keep the runner updated#
The runner application updates itself by default when a new version is published. If you disable that (common for container images, with --disableupdate), you must ship a new version within 30 days of a release, or GitHub stops sending jobs to the runner. When a critical security update is required, GitHub also stops sending jobs to the runner until it’s updated.
Since September 2026, the REST API ↗ also returns the dates when a runner version stops being able to register and to run jobs (GET /repos/{owner}/{repo}/actions/runners/deprecations/{version}, and the same path under /orgs/{org}). New action versions need recent runners too: actions/checkout v5 and later run on Node 24 and need runner v2.327.1 or later. Subscribe to the actions/runner releases ↗ and build runner upgrades into your image pipeline instead of updating by hand.
6. Lock it down#
- Put runners in a runner group that only the repositories that need them can use. By default, a runner group’s runners aren’t available to public repositories: keep it that way unless those runners are isolated as Before you start describes.
- Run the service as a dedicated user without sudo (step 2 shows how). If container jobs need that user in the
dockergroup, it can still get root: Docker warns ↗ that the group grants root-level privileges. So don’t count on the user to isolate one job from the next: use ephemeral machines. - Don’t store long-lived cloud credentials on the machine. Use OIDC (
permissions: id-token: write) to get short-lived credentials per job, scoped to an environment for deploys. - Treat jobs on
pull_request_target,issue_commentandworkflow_runas privileged, and never run fork code on a runner that has access to secrets. See pull_request vs pull_request_target. - Pin third-party actions to a full commit SHA, or commit a workflow dependency lockfile ↗ (generally available since October 2026) that pins every action your workflows use, transitive ones included. A tag can be moved to other code, which then runs on your runner. The lockfile doesn’t cover calls to reusable workflows: pin those to a full commit SHA.
- Forward the runner’s logs (
_diag/) somewhere durable, especially with ephemeral runners: they vanish with the machine.
Scaling beyond one machine#
A single runner runs one job at a time. Once you have more than a handful, you need something that adds and removes machines with the queue. The main options:
| Option | Where jobs run | What you operate |
|---|---|---|
| Actions Runner Controller ↗ (ARC) | Pods in your Kubernetes cluster | The cluster, the controller, runner images |
| Runner Scale Set Client ↗ (GitHub, public preview) | VMs or containers you provision | The scaler you build with it, the machines, runner images |
| terraform-aws-github-runner ↗ (community module, formerly Philips Labs) | EC2 instances, via Lambda functions | The Terraform, the Lambdas, the AMIs |
| RunsOn | One EC2 instance per job, in your AWS account | One CloudFormation stack (or Terraform module) |
| Your own scripts | Wherever you like | Everything, including the scaler |
ARC is GitHub’s own autoscaler for Kubernetes, and the natural fit if you already run a cluster. Jobs run in containers, so images built for GitHub-hosted runners don’t carry over as-is. See our ARC on Kubernetes guide.
The Runner Scale Set Client is GitHub’s Go library for building an autoscaler outside Kubernetes, on the same scale-set APIs that ARC uses. As of November 2026 it’s in public preview. It handles the GitHub side, including just-in-time runner configurations, and your code creates and removes the machines. For a scaler of your own, GitHub suggests building on this client rather than on workflow_job webhooks at high volume, because webhook delivery can lag.
terraform-aws-github-runner (started at Philips Labs, now community-maintained) autoscales EC2 runners with webhooks and Lambda functions. It’s flexible and battle-tested, and it’s code you own: upgrades, AMIs and debugging are on you.
RunsOn (this site) runs each job on a fresh EC2 instance in your AWS account, from AMIs that match GitHub’s runner images, so workflows move over by changing their runs-on: label. It handles spot instances, caching, arm64, GPUs and Windows, and costs a license priced by monthly runner volume, plus your AWS bill. It has two modes: in Flex, each job’s label describes the runner it needs; in Fleet, a platform team defines and publishes the runners, and workflows pick one with a label such as runs-on/fleet=linux-small/env=production. See the quickstart.
How much does self-hosting save?#
The compute is cheaper: an EC2 spot instance costs a fraction of GitHub’s per-minute rate for the same vCPUs (our pricing comparison has the numbers per size). What eats the savings is the time to operate the fleet, idle machines, and over-provisioning. We break those costs down in the true cost of self-hosted runners.
In December 2025, GitHub announced a $0.002 per minute platform fee on self-hosted runner jobs from March 2026, then suspended it days later. As of November 2026, GitHub’s runner pricing lists no fee for self-hosted runners.
Should you self-host?#
Self-host when you need hardware beyond GitHub’s larger runners (more than 96 vCPUs, GPUs other than a single T4, specific CPU families), bigger machines on a plan without larger runners (they need Team or Enterprise Cloud), direct access to private networks outside Azure, lower costs at volume, or control over where code and secrets run. Stay on GitHub-hosted runners when your usage is small and nobody wants to own runner infrastructure. Managed providers sit in between: someone else’s machines, cheaper than GitHub, with your code on their infrastructure.
| GitHub-hosted | Managed provider | Self-hosted | RunsOn | |
|---|---|---|---|---|
| Machines | GitHub’s | The provider’s | Yours | EC2 instances in your AWS account |
| Where code and secrets run | GitHub’s infrastructure | The provider’s infrastructure | Your machines, in your network | Your AWS account |
| How you pay | GitHub, per minute beyond your plan’s included compute | The provider, per minute | Your cloud bill or your own hardware | AWS, plus a license priced by monthly runner volume |
| What you operate | Nothing | Nothing | The machines, images, updates and scaling | One CloudFormation stack (or Terraform module) |
Alternatives to GitHub-hosted runners compares managed providers and RunsOn in more detail.