Self-hosting
espresso-server is a single static binary. It keeps everything in one data directory: an SQLite database
and the recording files. It serves plain HTTP. Put a reverse proxy in front of it for TLS.
Quick start (binary)
espresso-server admin create-user alice --data ./data # the first user is an admin
espresso-server admin set-password alice --data ./data # for signing in on the web
espresso-server admin create-token alice --label laptop --data ./data # prints the API token once
espresso-server serve --data ./data # listens on 0.0.0.0:24870
Open http://localhost:24870/ to check it works. On your machine, run espresso auth login --server http://localhost:24870 and paste the token.
Every command takes --data DIR. The default is $ESPRESSO_DATA, or /data if that isn't set.
As a systemd service
# /etc/systemd/system/espresso-server.service
[Unit]
Description=espresso-server
After=network-online.target
Wants=network-online.target
[Service]
User=espresso
Group=espresso
ExecStart=/usr/local/bin/espresso-server serve
Environment=ESPRESSO_DATA=/var/lib/espresso
Environment=ESPRESSO_LISTEN=127.0.0.1:24870
Environment=ESPRESSO_BASE_URL=https://casts.example.org
Environment=ESPRESSO_TRUSTED_PROXIES=127.0.0.1/32,::1/128
StateDirectory=espresso
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
PrivateTmp=true
Restart=on-failure
[Install]
WantedBy=multi-user.target
sudo useradd --system --home /var/lib/espresso espresso
sudo systemctl daemon-reload && sudo systemctl enable --now espresso-server
sudo -u espresso ESPRESSO_DATA=/var/lib/espresso espresso-server admin create-user alice
On SIGTERM the server closes live streams (and saves them), then shuts down. This takes at most about 10
seconds.
Docker
The repository includes a multi-arch Dockerfile and an example compose.yaml in server/. No prebuilt
image is published yet, so build it yourself. The build context is the folder that holds server/,
format/, player/ and docs/ side by side:
docker build -f server/Dockerfile -t espressostream/server .
# several architectures at once:
docker buildx build --platform linux/amd64,linux/arm64 -f server/Dockerfile -t espressostream/server .
The image runs as a non-root user (uid 65532), keeps its data in the volume /data, listens on port
24870, and has a health check (espresso-server healthcheck, which requests /healthz). Its root filesystem
can be read-only.
cd server
docker compose up -d
docker compose exec espresso espresso-server admin create-user alice
docker compose exec espresso espresso-server admin create-token alice --label laptop
The example compose file publishes the port on 127.0.0.1 only, drops all capabilities and sets
ESPRESSO_BASE_URL / ESPRESSO_TRUSTED_PROXIES for a reverse proxy on the host. It puts the container on a
network with a fixed subnet (172.30.0.0/24), so the address the proxy's connections arrive from, the bridge
gateway 172.30.0.1, is known and is the only one trusted. Edit the URL before you start it. If your proxy
runs in the same compose project, give it a fixed address on that network and trust that address instead.
The Dockerfile and the compose file were written without Docker available. Treat them as a starting point and check them on your machine. Plain binaries are the tested path.
Reverse proxy and TLS
The server speaks plain HTTP. Terminate TLS in a reverse proxy and tell the server about it:
ESPRESSO_BASE_URL=https://casts.example.org: absolute links in API responses and oEmbed use it, and anhttps://URL makes sign-in cookiesSecure.ESPRESSO_TRUSTED_PROXIES=127.0.0.1/32,::1/128: the addresses (IPs or CIDR prefixes, comma-separated) of your reverse proxies.X-Forwarded-Proto,X-Forwarded-HostandX-Forwarded-Forare used only on requests that come from one of them; from anyone else they are ignored, so clients can't fake their IP address to get around rate limits. List only the proxy itself, never a whole network that clients can reach. The client IP is the rightmostX-Forwarded-Forentry that isn't a trusted proxy.- HSTS (
Strict-Transport-Security: max-age=31536000) is sent only on requests that really came over HTTPS: over TLS, or from a trusted proxy that saysX-Forwarded-Proto: https. Anhttps://base URL alone makes cookiesSecurebut doesn't send HSTS. ESPRESSO_TRUST_PROXY=1(older setting) still works and now means loopback only (127.0.0.1,::1). It is ignored whenESPRESSO_TRUSTED_PROXIESis set, so you only need the list.- If the server keeps getting requests from one private or loopback address that isn't trusted, it logs a warning once that suggests the setting.
The proxy has to pass WebSocket upgrades through for live streams (/api/v1/streams and
/api/v1/streams/<id>/watch) and allow uploads up to 50 MB.
Caddy (gets certificates automatically):
casts.example.org {
request_body {
max_size 50MB
}
reverse_proxy 127.0.0.1:24870
}
nginx:
server {
listen 443 ssl;
http2 on;
server_name casts.example.org;
ssl_certificate /etc/letsencrypt/live/casts.example.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/casts.example.org/privkey.pem;
client_max_body_size 50m;
location / {
proxy_pass http://127.0.0.1:24870;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 1h; # live streams can be quiet for a while
}
}
# in the http {} block:
map $http_upgrade $connection_upgrade { default upgrade; '' close; }
Accounts and sign-up
- The first user you create is an admin. Admins manage users, invites and the sign-up mode on
/admin. They cannot see other users' private recordings. - Sign-up mode (
--signup/ESPRESSO_SIGNUP):closed(default): only admins create users, withespresso-server admin create-user.invite: people sign up with a single-use link that expires. An admin creates the link withespresso-server admin create-invite [--ttl 168h]or on/admin.open: anyone can sign up at/signup.
- Users sign in at
/loginand manage their password, sessions and API tokens on/settings.
Admin commands:
espresso-server admin create-user NAME [--admin]
espresso-server admin set-password NAME (reads the password from the terminal or stdin)
espresso-server admin set-admin NAME on|off
espresso-server admin create-invite [--ttl 168h]
espresso-server admin create-token NAME [--label LABEL] [--scope full|upload]
espresso-server admin list-users
espresso-server admin list-tokens NAME
espresso-server admin revoke-token TOKEN_ID
espresso-server admin reindex (rebuild the search index)
A token is shown once when it is created. Only a hash of it is stored.
The data directory
| Path | Contents |
|---|---|
db.sqlite |
users, password hashes, token hashes, sessions, invites, recording metadata, search index |
casts/<id>.cast |
recordings, uncompressed |
casts/<id>.cast.trace.jsonl |
exec traces, for recordings that have one |
snapshots/pre-v<N> |
copy of the database from before a schema upgrade (see Updating) |
Recording ids are random, so there is nothing to guess.
Backups and restore
espresso-server backup /backups/espresso-$(date +%F).tar.zst # safe while the server is running
espresso-server backup - | ssh backup-host 'cat > espresso.tar.zst'
ssh backup-host 'cat espresso.tar.zst' | espresso-server restore - --data /var/lib/espresso # - reads stdin
A backup is a zstd-compressed tar file. It holds a consistent snapshot of the database and every recording and trace file.
To restore, stop the server first:
espresso-server restore espresso-2026-12-03.tar.zst --data /var/lib/espresso
restore refuses to write into a data directory that already has a database or recordings, unless you pass
--force. It unpacks and checks the archive before it replaces anything, and it accepts only the files a
backup contains. Practise a restore into an empty directory now and then.
With Docker (-T: no terminal, so the binary archive passes through unchanged):
docker compose exec -T espresso espresso-server backup - > espresso.tar.zst
# restore: stop the server, run the restore in a one-off container on the same volume, start again
docker compose stop espresso
docker compose run --rm -T espresso restore - --force < espresso.tar.zst
docker compose start espresso
Retention and limits
| Setting | Default | Effect |
|---|---|---|
--unlisted-ttl / ESPRESSO_UNLISTED_TTL |
keep | delete unlisted recordings older than this (e.g. 720h), checked hourly |
--quota / ESPRESSO_QUOTA |
unlimited | storage per user, e.g. 2G. When a user is over it, new uploads and streams are refused |
| upload size | 50 MB raw, 10 MB gzip-compressed | larger uploads get HTTP 413 |
| recording length | 6 h | longer recordings are rejected |
--max-events |
5 000 000 | events per recording |
Public and private recordings are kept until their owner deletes them. Rate limits for sign-in, uploads, streams and search are listed in Configuration.
Health and monitoring
GET /healthz returns 200 when the server is up. espresso-server healthcheck [--url URL] calls it and
sets its exit status, for container health checks. The server logs to standard error, including every
recording that retention deletes.
Updating
Stop the server, replace the binary (or pull and rebuild the image), and start it again. Make a backup
first. If the new version changes the database schema, the server first copies the database to
snapshots/pre-v<N> in the data directory (N is the new schema version; the folder is readable only by
the server's user). It then applies all changes in one transaction, so a
failed upgrade leaves the database as it was. The log says database migrated with the snapshot's path.
A server refuses to start on a database written by a newer version.
To go back to the old version after an upgrade:
sudo systemctl stop espresso-server
cd /var/lib/espresso
mkdir -p old && mv db.sqlite db.sqlite-wal db.sqlite-shm old/ 2>/dev/null
cp snapshots/pre-v1 db.sqlite
# install the old binary, then
sudo systemctl start espresso-server
Changes made after the upgrade (new users, tokens, metadata) are lost. Recordings uploaded after the upgrade
stay in casts/ but are no longer listed. Snapshots aren't part of backups and aren't removed
automatically: delete them once the new version has run fine for a while. Restoring an older backup works
the same way: it is upgraded during the restore, and the backup file itself is your copy of the old state.