On this page
When does a self-hosted runner make sense?
A self-hosted runner pays off when jobs need more CPU or memory than hosted machines, a fixed IP for deployment firewalls, cached dependencies that stay warm between jobs or access to a private service. The runner only makes outgoing HTTPS connections to GitHub and polls for work, so you open no inbound port for it.
The trade-off is that you own the machine: patches, disk cleanup and above all isolation between jobs. Each job runs arbitrary code from the workflow file with the permissions of the runner user. That is the reason for the security rules further down. The CI runners solution page describes how the plan lines fit different build loads.
How do you prepare the host for the runner?
Use a fresh Ubuntu 24.04, Debian 12/13, Rocky Linux 9 or AlmaLinux 9 server, update it and create a user that owns the runner. The runner refuses to configure as root by default, and that default is worth keeping.
sudo apt update && sudo apt full-upgrade -y # Rocky/Alma: sudo dnf upgrade -y
sudo useradd -m -s /bin/bash runner
sudo -iu runner
mkdir actions-runner && cd actions-runnerMost workflows also expect git, curl, jq and unzip. If your jobs build containers, install Docker Engine, but note that membership of the docker group equals root on the host. Keep SSH hardened as in SSH keys and hardening.
How do you download and register the runner?
Open the repository (or organization) on GitHub, go to Settings, Actions, Runners, click New self-hosted runner and choose Linux x64. The page shows the current version, a checksum and a registration token valid for one hour. The commands look like this, with the version and token taken from that page:
RUNNER_VERSION=2.330.0 # copy the version shown on the page
curl -fLo actions-runner.tar.gz \
https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz
echo "CHECKSUM_FROM_PAGE actions-runner.tar.gz" | sha256sum -c
tar xzf actions-runner.tar.gz
exit
sudo /home/runner/actions-runner/bin/installdependencies.sh
sudo -iu runner
cd actions-runner
./config.sh --url https://github.com/example-org/myapp --token REGISTRATION_TOKEN \
--name vps-01 --labels linux,x64,vps --unattendedThe dependency script installs the .NET runtime libraries the runner needs (ICU, OpenSSL and similar) with apt or dnf. After config.sh the runner appears as Offline in the list until the service starts.
How do you run the runner as a service?
The package includes svc.sh, which writes a systemd unit for you. Run it from the runner folder with sudo and pass the user that should own the process:
exit # back to your sudo user
cd /home/runner/actions-runner
sudo ./svc.sh install runner
sudo ./svc.sh start
sudo ./svc.sh status
systemctl list-units 'actions.runner.*' --no-pagerThe unit name follows the pattern actions.runner.ORG-REPO.NAME.service, so journalctl -u 'actions.runner.*' -f streams the logs. Refresh the GitHub runners page and the runner turns Idle. Point a workflow at it with its labels:
jobs:
build:
runs-on: [self-hosted, linux, vps]
steps:
- uses: actions/checkout@v5
- run: make testIs a self-hosted runner safe on a public repository?
Not without extra care: on a public repository anyone can open a pull request whose workflow runs on your server. A persistent runner keeps files, caches and processes from one job to the next, so a hostile job can plant something that steals secrets from a later trusted job. GitHub itself recommends self-hosted runners mainly for private repositories. If you must use one on a public project:
- Under Settings, Actions, General require approval for workflow runs from all outside collaborators, and review each fork pull request before approving.
- Never use the
pull_request_targettrigger to check out and run code from a fork on the self-hosted runner. - Run only ephemeral runners, so every job starts on a clean registration and nothing survives it.
- Keep production credentials out of the runner host; give workflows short lived tokens with the minimum
permissions:block. - In an organization, put self-hosted runners in a runner group limited to selected repositories.
How do ephemeral runners work?
An ephemeral runner accepts exactly one job, then unregisters itself and exits. Add --ephemeral when you configure it, and something outside the runner has to register a new one for the next job. Because registration tokens expire after an hour, automation fetches a fresh one through the REST API with a token that has administration rights on the repository:
#!/bin/bash
# /home/runner/run-ephemeral.sh, started by a systemd unit with Restart=always
set -euo pipefail
cd /home/runner/actions-runner
TOKEN=$(gh api -X POST repos/example-org/myapp/actions/runners/registration-token --jq .token)
./config.sh --url https://github.com/example-org/myapp --token "$TOKEN" \
--name "vps-$(date +%s)" --labels linux,x64,vps --ephemeral --unattended --replace
./run.shFor real isolation the job should also start from a clean file system, for example by running the runner inside a fresh container for each job or by resetting a work directory, because ephemeral registration alone does not wipe the disk. The API also offers just in time configurations (generate-jitconfig) that create a one job runner without calling config.sh at all.
How do you keep the runner healthy?
The runner updates itself when GitHub releases a new version, which needs write access to its own folder; do not make it read only. Routine care:
- Watch disk space in
_workand Docker storage;docker system prune -af --filter until=72hin a weekly timer keeps image caches in check. - Apply OS updates and reboot during quiet hours; the service starts again by itself.
- Check resource use with usage monitoring and move to a larger plan if jobs queue.
To remove a runner, stop and uninstall the service, then unregister it with a removal token from the runners page:
sudo ./svc.sh stop && sudo ./svc.sh uninstall
sudo -u runner ./config.sh remove --token REMOVAL_TOKENPlans that fit this guide
Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.
Questions about Self-hosted GitHub Actions runner
Does the runner need any open ports?
No. It connects out to GitHub over HTTPS on port 443 and long polls for jobs, so the firewall can block all inbound traffic except SSH.
Can one server run several runners?
Yes. Create a separate folder per runner, configure each with its own name and install each service. Give them labels so heavy jobs do not pile onto one small server.
Why is my runner shown as offline?
The service is stopped or cannot reach GitHub. Check sudo ./svc.sh status and the journal, and confirm that DNS and outbound HTTPS work.
Can I run the runner as root?
Only by setting RUNNER_ALLOW_RUNASROOT=1, which is a bad idea: every workflow would then control the whole server.
Which plan suits a runner?
Builds are CPU bound, so the High Frequency and AMD EPYC lines suit them well. Start with 2 vCPU and 4 GB for typical web projects and grow if jobs queue.