# Manage self-hosted runners

Check status and logs, upgrade kosem-runner without stopping environments, pause or remove runners, and require self-hosted runners by policy.

Monitor, upgrade, pause and remove self-hosted runners, or require projects to run environments exclusively on them. Viewing pools and runners requires any basic role or an Environment role; pausing, resuming and deleting runners requires Owner, Editor or Environment Admin. Changing organization pool sharing requires Owner on the organization, and setting policies requires Owner or Policy Admin on Team or Enterprise.

## Check runner status and logs [#check-runner-status-and-logs]

In the console, open **Environments** › **Runners** and click a runner's name to view its state, capacity usage, placed environments and host details.

On the host, run `status` to inspect registration, service state, environments (including failing environment errors) and available upgrades, or `check` to verify host prerequisites:

```sh
# Linux
sudo kosem-runner status
sudo kosem-runner check
sudo journalctl -u kosem-runner -n 50

# macOS
kosem-runner status
kosem-runner check
tail -n 50 ~/Library/Logs/kosem-runner/runner.log
```

If a runner is **Offline**, environments placed on it wait until it reconnects because their disks are stored on that host. Confirm outbound HTTPS connectivity to `https://api.kosem.ai`, inspect the logs above, and on macOS verify that Apple's `container` services are running with `container system status` (start them with `container system start`).

## Upgrade kosem-runner [#upgrade-kosem-runner]

When kosem publishes a newer version of `kosem-runner`, the runner's console page shows an upgrade notice and `kosem-runner status` reports it. Upgrading keeps the runner's registration, saved installer flags and running environments:

```sh
sudo kosem-runner upgrade   # Linux
kosem-runner upgrade        # macOS
```

On Linux, `upgrade` also refreshes `containerd`, Kata Containers and CNI while existing microVMs continue running. On macOS, it prompts for `sudo` only if the `pf` firewall rules changed.

## Pause and resume a runner [#pause-and-resume-a-runner]

Pause a runner before host maintenance so kosem places new environments on other runners in the pool. Existing environments stay on the host until deleted, and a paused runner still counts toward your **Self-hosted runners** quota.

1. In your organization or project, click **Environments**, and then **Runners**.
2. Click the runner's name.
3. Click **Pause**. To accept new environments again, click **Resume**.

With the API, set your API key ([Call the API](/get-started/call-the-api)) and the runner's IDs, then call `/pause` (or `/resume`, which schedules waiting environments in the pool immediately):

```sh
export KOSEM_API_KEY='kosem_sk_…'
export KOSEM_ORG='org_01m5r8w2k3e9vbt6g0d4x7qz1h'
export KOSEM_POOL='rnp_01m5rh2kq2e9vbt6g0d4x7qz1t'
export KOSEM_RUNNER='rnr_01m5rh6mq2e9vbt6g0d4x7qz1u'

curl -s -X POST "https://api.kosem.ai/v1/organizations/$KOSEM_ORG/runnerPools/$KOSEM_POOL/runners/$KOSEM_RUNNER/pause" \
  -H "Authorization: Bearer $KOSEM_API_KEY"
```

For a project pool, replace `/organizations/$KOSEM_ORG` with `/projects/{project}`.

## Rename a pool or change sharing [#rename-a-pool-or-change-sharing]

Use `PATCH` to rename a runner pool or (for an organization pool, as an Owner) change which projects can use it. Environments in a project removed from `availability` continue running until stopped, then can't start again in that pool:

```sh
curl -s -X PATCH "https://api.kosem.ai/v1/organizations/$KOSEM_ORG/runnerPools/$KOSEM_POOL" \
  -H "Authorization: Bearer $KOSEM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"displayName": "Linux build hosts", "availability": {"allProjects": false, "projects": ["projects/prj_01m5r9dh9mf0ps98ktkap3562c"]}}'
```

## Remove a runner or delete a pool [#remove-a-runner-or-delete-a-pool]

:::warning
Removing a runner deletes every environment disk stored on its host. Remaining environments lose their disks and start fresh from their images on another runner in the pool. This can't be undone.
:::

### Uninstall from the host [#uninstall-from-the-host]

When you still have access to the host, run `uninstall`. It stops the service, deletes local VMs and disks, deletes the runner in kosem (freeing its quota slot immediately) and removes service files, firewall rules, symlink and logs:

```sh
sudo kosem-runner uninstall   # Linux
kosem-runner uninstall        # macOS
```

Pass `--yes` (`-y`) to skip confirmation in scripts. If the host can't reach kosem, `uninstall` removes local files and instructs you to delete the runner in the console so it stops counting toward your quota.

### Delete from the console [#delete-from-the-console]

If a host is gone or unreachable, delete its runner in the console:

1. Open **Environments** › **Runners** and click the runner.
2. Click **Delete**.
3. If environments are placed on the runner, enter the runner's name to confirm, then click **Delete runner**.

kosem revokes the host's credentials immediately and frees its quota slot. If the host reconnects later with an accurate clock, it wipes its local VMs, disks and key and stops; run `kosem-runner uninstall` on the host to remove the binary and service files.

### Delete an empty pool [#delete-an-empty-pool]

Once a pool has no runners and no active environments, open **Environments** › **Runners**, click the delete icon beside the pool's name and click **Delete pool**.

## Require self-hosted runners with a policy [#require-self-hosted-runners-with-a-policy]

On Team and Enterprise, Owners and Policy Admins can prevent projects from using kosem-managed machines:

1. Open **Settings** › **Policies** on your organization or project ([Set organization and project policies](/guides/access/set-policies)).
2. Beside **Require self-hosted** (`environments.selfHostedRequired`), click **Edit**.
3. Select **Enforce** and click **Save**.

New environments can run only on self-hosted runner pools, and existing agents on kosem-managed machines won't start again until moved to a runner pool.

## Related [#related]

- [Self-hosted runners](/concepts/self-hosted-runners)
- [Set up a self-hosted runner](/guides/environments/set-up-a-self-hosted-runner)
- [Policies](/concepts/policies)
- [Errors](/reference/errors#environments)
