KlangDocs

    Open Klang

    Self-hosting

    View as Markdown

    Troubleshooting

    How to see what’s wrong, and the usual problems: certificates, a service that won’t start, files or voice that don’t load, email that doesn’t arrive.

    Reading the logs

    Everything starts from selfhost/:

    Shell
    docker compose ps                  # every service, its state and its healthcheck
    docker compose logs -f api         # one service's log, live (Ctrl+C to stop)
    docker compose logs --since 10m    # all of them, the last ten minutes

    The services are caddy, web, admin, api, gateway, bot-gateway, postgres, valkey, s3, livekit, and the two that run once at each start, migrate and s3-init (Exited (0) is right for those two). A service marked unhealthy or restarting over and over says why in its log. For more detail, LOG_LEVEL=debug in .env and docker compose up -d.

    Pulling the images fails

    • denied or unauthorized for a klang-… image: the registry refused you. Either the images aren’t public yet (just after a release is tagged), or KLANG_IMAGES points at a private mirror you haven’t signed in to (docker login). Wait for the release’s images, or build them yourself with docker compose build.
    • manifest unknown or not found for a klang-… image: the version doesn’t name a release. Leave KLANG_VERSION commented in .env, so the tag you checked out names its own images. If you set it, it’s the version without the v (0.0.31, not v0.0.31).
    • no matching manifest for linux/arm/v7 (or another platform): the machine isn’t 64-bit. The images are only linux/amd64 and linux/arm64 (Requirements).

    A service won’t start

    • Invalid environment configuration. The process cannot start. in api, gateway or bot-gateway, followed by the variables at fault:
      • still change-me from .env.example: run sh init-env.sh, or set that secret by hand.
      • KLANG_EDITION: it’s missing. The kit’s compose file sets it to self; you only see this if you run the images some other way. Set KLANG_EDITION=self in their environment.
      • Any other: the message says what the value must look like.
    • s3-init: an S3 key is still change-me: the same, for the store’s keys.
    • valkey: VALKEY_PASSWORD must be set: the same, for Valkey’s password. Set by hand, it can only have letters, digits, ., _, ~ and -.
    • required variable VALKEY_PASSWORD is missing a value from any docker compose command: your .env lacks the line. Copy it from .env.example and run sh init-env.sh.
    • port is already allocated or address already in use for 3478/udp: something else on the machine uses the TURN port. UniFi’s Network application does (its STUN server). Move Klang’s with LIVEKIT_TURN_PORT=3479 in .env, open that port instead, and run docker compose up -d. The same goes for 7881 and 7882 (LIVEKIT_TCP_PORT, LIVEKIT_UDP_PORT).
    • ARM64-COW-BUG in valkey, which then won’t start: Valkey checks the kernel for an old ARM64 memory bug when it starts. Under emulation (an arm64 image on an x86 machine, with QEMU) that check fails even though nothing is wrong. On a real ARM machine with an up-to-date kernel you won’t see it. Only for an emulated or test setup, copy the command of the valkey service into compose.override.yml and add --ignore-warnings ARM64-COW-BUG after --appendonly yes. Never on a real server: there the warning means the kernel needs updating.
    • Permission denied in caddy, postgres, valkey or s3: no service runs as root, so each volume has to belong to its service’s user. The kit’s own volumes do; one made some other way may not. Restore files as Backups says: its commands keep each file’s owner.
    • migrate exited with an error: docker compose logs migrate. After an update, restore the backup you made before (Updating).
    • Everything waits: the API and the gateways wait for migrate and s3-init, and Caddy waits for the rest to be healthy. Look for the first one that isn’t.

    The site doesn’t open, or the browser warns about the certificate

    Caddy gets the certificates from Let’s Encrypt the first time each name is visited.

    • The four hostnames must point at this server (dig +short chat.example.org).
    • Ports 80 and 443 must reach the server from the internet: Let’s Encrypt checks through port 80.
    • docker compose logs caddy says what Let’s Encrypt answered. After several failures it makes you wait (its rate limits): fix the cause, then wait.
    • Trying it on your computer with compose.local.yml, the browser warns once for each of the four hostnames: open the files and voice addresses once and accept them too, or files and calls won’t load.

    Files or avatars don’t load

    • Open a file’s address directly: if the certificate or the hostname fails, see above (KLANG_FILES_DOMAIN).
    • docker compose logs s3-init must end with S3 store ready.
    • Uploads fail at once: check LIMIT_UPLOAD_MB and that the disk isn’t full (df -h).

    Voice doesn’t connect

    People join the channel but hear nothing, or the call keeps reconnecting:

    1. Ports: 7881/TCP, 7882/UDP and 3478/UDP open in the firewall, and forwarded in the router if the server is at home (Requirements).
    2. The address LiveKit announces must be the public one (Voice and TURN).
    3. Only from some places (an office, a school, a hotel): their network probably only lets HTTPS out, and the kit has no TURN over TLS yet (the limitation).
    4. Only from inside your own network: your router needs NAT loopback (NAT).

    Email doesn’t arrive

    docker compose logs api | grep -i email:

    • email not sent: neither RESEND_API_KEY nor SMTP_URL: there’s no provider in .env.
    • An SMTP error (login refused, timeout, TLS): check the URL, its port (smtp:// for 587, smtps:// for 465) and percent-encoded characters in the password.
    • No error but nothing in the inbox: look in spam, and check that the domain of EMAIL_FROM allows your SMTP server to send for it (SPF, DKIM).

    See Email.

    Bots can’t connect

    • BOTS_ENABLED must be true: bots are off by default.
    • The bot’s library must use your hostnames: https://<KLANG_DOMAIN>/api for the API and https://<KLANG_DOMAIN>/api/media for images (Bots).

    The app stays on “Offline, reconnecting”

    Each IP can open GATEWAY_CONNECTIONS_PER_5_MIN real-time connections every 5 minutes (60 by default). Many tabs or people behind one IP (testing on one computer, an office, a school) can use them up, and the app waits until the 5 minutes pass. Raise the value in .env and run docker compose up -d (Configuration).

    If it happens to everyone at once, Klang may be seeing one address for all of them: behind your own reverse proxy without TRUST_PROXY_HOPS=2 (Behind your own reverse proxy), or with AAAA records while Docker’s network has no IPv6 (IPv6).

    Two installs on one machine

    The kit’s project is called klang-server, and its volumes start with that name. A second install on the same machine needs its own folder and its own project name, in every command: docker compose -p klang-other …. Otherwise both would share the same volumes.

    Still stuck

    Search the repository’s issues, and open one with the bug template if it’s a bug: what you did, what happened, and the relevant lines of the logs. Remove every secret first: no .env, no tokens, no passwords.