> ## Documentation Index
> Fetch the complete documentation index at: https://sandkiln.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Troubleshooting

> Symptoms you are likely to hit while self-hosting sandkiln, with the cause and the fix for each.

Run `scripts/preflight-check.sh` first; it reports most of these before they bite. For the steps behind each fix see [Manual host setup](https://sandkiln.mintlify.site/self-hosting/manual-setup.md).

## Setup and permissions

* **`scripts/setup.sh` fails with "a terminal is required to read the password".** It ran non-interactively (for example `ssh host 'cmd'` rather than an interactive session) and one of its `sudo` steps had no TTY to prompt on. Run it from a real interactive shell, or run `sudo -v` first to cache credentials in that session before invoking it non-interactively.
* **A rebuild-then-restart over SSH cannot prompt for sudo.** Run `sudo scripts/host-setup/allow-passwordless-cap-grant.sh` once, interactively, so `sandkilnd-ctl.sh restart` can grant `CAP_NET_ADMIN` unattended.
* **`/dev/kvm: permission denied`.** `sudo usermod -aG kvm $USER`, then log in again; group membership does not apply to an already-open session.
* **"Operation not permitted" on any network call.** You rebuilt the daemon and are running it directly, not under the systemd unit, and did not re-run `sudo scripts/host-setup/grant-net-admin.sh core/target/release/sandkilnd`. Capabilities do not survive a rebuild; `sandkilnd-ctl.sh` and the systemd unit handle it. See [Capabilities](https://sandkiln.mintlify.site/self-hosting/manual-setup.md#capabilities).
* **`preflight-check.sh --root-checks` reports missing binaries you know are installed.** You ran it with plain `sudo`, which resets `$HOME` to `/root` and breaks every `~/sandkiln-tools/...` default path. Use `sudo -E` to preserve your environment.

## Startup

* **`tap devices missing: [...] — run scripts/host-setup/create-tap-pool.sh first` at startup.** `tap_pool_prefix` or `tap_pool_size` (`SANDKILN_TAP_POOL_PREFIX` and `SANDKILN_TAP_POOL_SIZE`) do not match what you created, or the pool was created for a different user than the daemon runs as.

## Sandboxes

* **Creating or resuming a sandbox returns `503` "no free tap devices left in the pool".** Every tap is plugged into a running sandbox (held snapshots do not use one). `GET /status` shows `tap_pool.in_use`; stop sandboxes you no longer need, or raise `tap_pool_size` after re-running `create-tap-pool.sh`. If the message is "no free IPs left in the sandbox subnet" instead, held snapshots are the cause: each keeps one of the 253 addresses, and `ip_pool.held_by_snapshots` says how many. Delete snapshots you will not resume.
* **Create works, but `exec`, `read-file` or `write-file` time out or fail with a vsock connect error.** The guest agent is not baked into the rootfs `base_rootfs` points at. Run `sudo -E scripts/preflight-check.sh --root-checks` to confirm, then see [Base image and guest agent](https://sandkiln.mintlify.site/self-hosting/manual-setup.md#base-image-and-guest-agent).
* **A plain `exec` returns `504`.** If the body has `"timed_out": true`, the command ran past its `timeout_secs` (default `exec_timeout_secs`, 600) and the guest killed it; the body carries the partial output, and a larger `timeout_secs` (up to `exec_timeout_secs`, which you can raise) or streamed exec is the way to run it longer. A `504` without `timed_out` means the guest did not answer at all: the command may still be running, most often because the guest agent in the image predates `timeout_secs` and needs re-injecting.
* **`exec` returns exit code `127` or `126` with a one-line message on `stderr`.** The command could not start: `127` means it was not found (`command not found`, or `No such file or directory` for a path), `126` means it exists but is a directory, lacks the execute bit or is not a loadable binary. It is the shell convention, not a daemon fault; install the program in the image or fix the path. A `500` "unexpected agent response: No such file or directory" on exec means the guest agent in the image predates this behaviour and needs re-injecting.
* **A remote storage mount returns `400` "remote storage mounts need the rclone binary..." or "...no /dev/fuse".** The sandbox image has no `rclone` (see `images/inject-rclone.sh`), or the guest kernel was built without `CONFIG_FUSE_FS` (see `images/build-guest-kernel.sh`). Use a FUSE-capable kernel and an image with rclone injected.
* **Sandboxes boot but have no outbound network.** Confirm `uplink_iface` detected the right interface (`ip route show default`), and that the DNS forwarder is running (`systemctl status sandkiln-dnsmasq`, or `scripts/host-setup/start-dns-proxy.sh` by hand). Outbound IP connectivity and DNS resolution are independent failure modes, so check both.

## Production image build

* **debootstrap fails on an unknown codename.** Your host's `debootstrap` does not yet know the Ubuntu release `build-universal-image.sh` defaults to. Either `apt-get install --only-upgrade debootstrap`, or pass an older LTS codename explicitly as its third argument (the script's header comment has the exact command).
* **Disk fills up during the build.** It needs several GiB free for the whole build (the sparse image itself plus package downloads inside the chroot). Free space first rather than letting it fail partway. The script cleans up a partial image on failure, but that does not reduce the headroom the next attempt needs.

## Jailer

* **Sandbox creation fails with a jailer-related error after enabling `jailer_enabled`.** Almost always the setuid bit on the `jailer` binary. Check `ls -la ~/sandkiln-tools/bin/jailer` shows `-rwsr-xr-x` owned by `root`, and re-apply `chown root:root` and `chmod u+s` if you re-ran `install-firecracker.sh` since. If it is set correctly and the jailer still fails, check `mount | grep cgroup2`: the jailer is invoked with `--cgroup-version 2` unconditionally and fails on a host still using the legacy cgroups v1 hierarchy. See [Jailer setup](https://sandkiln.mintlify.site/self-hosting/jailer.md).
* **`400 snapshotting a jailed sandbox is not supported yet`.** Expected. Stop the sandbox instead of snapshotting it if you do not need to resume it.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.