Edit

Commands

Full reference for all LearnHouse CLI commands.

Global options

These options go before the command name.

OptionDescription
--dir <path>Installation directory to act on. Defaults to the current directory when it holds an installation, otherwise the installation under ~/.learnhouse. Same as setting LEARNHOUSE_DIR.
-V, --versionPrint the CLI version
-h, --helpShow help (also works after a command, for example npx learnhouse setup --help)
npx learnhouse --dir ~/.learnhouse/production status

See Choosing an installation for how the CLI picks an installation when you don't pass --dir.

Interactive and non-interactive use

setup --ci, start, stop, update, status, health, doctor, config, logs, backup and restore --yes run without prompts, so you can use them in scripts and CI.

env, scale, deployments, shell and setup (without --ci) need a terminal. Without one they print an error and exit with code 2.

health and doctor exit with code 1 when a check fails. Any command that fails exits with code 1. Set LEARNHOUSE_DEBUG=1 to print the stack trace of an unexpected error.

setup

Interactive wizard that generates a complete Docker Compose deployment. See Setup Wizard for the steps.

npx learnhouse@latest setup
FlagDescription
--ciNon-interactive mode with defaults (for CI and automation)
--name <name>Installation name (default: default). The installation goes in ~/.learnhouse/<name>.
--domain <domain>Domain name or the server's IP address (default: localhost)
--port <port>HTTP port (default: 80, or 443 with --https auto). Without this flag, --ci falls back to another free port when it is taken.
--https <mode>auto (Let's Encrypt certificate through Caddy; needs a domain name and ports 80 and 443), manual (TLS ends at your own proxy) or off (default). A re-run without it keeps the install's current mode.
--ssl-email <email>Let's Encrypt contact for --https auto (default: --admin-email)
--admin-email <email>Admin email (default: [email protected])
--admin-password <password>Admin password, at least 8 characters. Required in --ci mode, or set LEARNHOUSE_ADMIN_PASSWORD.
--org-name <name>Organization display name (default: Default Organization)
--org-slug <slug>Organization slug used in URLs (default: default)
--channel <channel>Release channel: stable or dev (default: stable)
--no-startWrite the files but don't start services
--external-db <uri>Use an external PostgreSQL (for example Supabase) instead of the in-container database. Or set LEARNHOUSE_EXTERNAL_DB.
--external-redis <uri>Community only: use an external Redis instead of the in-container Redis. Or set LEARNHOUSE_EXTERNAL_REDIS.
--docker-ipv6Enable IPv6 on the compose network (needed for IPv6-only external databases)
--install-dir <dir>Override the install directory (default: ~/.learnhouse/<name>)

Re-running setup --ci on an existing installation reconfigures it in place. It keeps the deployment, secrets, HTTPS mode, the AI, email, S3 and OAuth settings, and any variables you added to .env yourself.

Enterprise Edition flags:

FlagDescription
--edition <edition>community (default) or enterprise
--license <key>Enterprise license key, also used as the image registry password. Or set LEARNHOUSE_LICENSE_KEY.
--tenancy <mode>single (default) or agency (multi-tenant)
--acme-email <email>Let's Encrypt contact email (default: the admin email)
--ee-image-tag <tag>Enterprise image tag (default: prod)
--local-tlsUse Caddy's internal CA (self-signed certificates, for testing only)
--dns-provider <provider>DNS-01 provider for wildcard certificates (cloudflare)
--cf-api-token <token>Cloudflare API token (Zone:DNS:Edit) for DNS-01. Or set LEARNHOUSE_CF_API_TOKEN.

In --ci mode the CLI validates every value before it changes anything: the admin email must use a real domain (reserved domains such as example.com and TLDs such as .local or .test are rejected), the slug must be lowercase letters, digits and single hyphens, and the installation name must start with a letter or digit, use only letters, digits, ., _ or -, and can't be a name Windows reserves (con, nul, com1, and so on).

# Setup without prompts. The password comes from the environment so it
# stays out of the process list and shell history.
LEARNHOUSE_ADMIN_PASSWORD=secretpass123 npx learnhouse setup --ci \
  --name production \
  --domain example.com \
  --admin-email [email protected]

Re-running setup on an existing installation (same --name or directory) reconfigures it in place. The deployment ID, database password, secrets and app image are kept, so your data stays attached. To move to a newer image, use update.

start

Start all containers for your deployment (docker compose up -d). The first start pulls the images. After you edit .env by hand, run start again: it recreates the containers whose configuration changed.

npx learnhouse start

On Community installations created before the content volume existed, start first moves uploaded files into a persistent Docker volume.

stop

Stop all running containers (docker compose stop). Containers and data volumes are kept, so start resumes them as they were.

npx learnhouse stop

status

Print the public URL and the output of docker compose ps for the installation.

npx learnhouse status

health

Run health checks against the running deployment and report the results.

npx learnhouse health

Checks:

  • Container state for every service
  • PostgreSQL readiness (pg_isready), skipped for external databases
  • Redis ping, skipped for external Redis
  • The public health endpoint (<url>/api/v1/health) and its response time
  • Docker disk usage (docker system df)
  • CPU, memory and network usage per container

Exits with code 1 if any check fails.

logs

Stream logs from all containers (docker compose logs --tail all -f). Press Ctrl+C to stop.

npx learnhouse logs

config

Display installation metadata: CLI version that created it, creation date, directory, edition, URL and organization slug, plus the paths of learnhouse.config.json and .env.

npx learnhouse config

update

Update LearnHouse to the latest release or a specific version. See Updates for details.

# Update to the latest version on your release channel
npx learnhouse update

# Update to a specific version
npx learnhouse update --to 1.4.2
# or using the short form:
npx learnhouse update -v 1.4.2
FlagDescription
-v, --to <version>Target version, for example 1.4.2 or v1.4.2. Without it, stable installations move to the newest release and dev installations stay on :dev. Enterprise default: prod.
--migrateRun database migrations (this is the default)
--no-migrateSkip database migrations
--no-backupSkip the pre-upgrade database backup (not recommended for production)

What update does on a Community installation, in order:

  1. Backs up the database to backups/db-pre-upgrade-<timestamp>.sql.gz (unless --no-backup). This works for external databases too. If the backup fails, nothing changes.
  2. Stamps an Alembic baseline if the database was never migrated (installations created before Alembic tracking)
  3. Resolves the target image: with --to, checks that the version exists on ghcr.io/learnhouse/app; without it, picks the newest release (stable channel) or :dev (dev channel)
  4. Moves uploaded files into a persistent Docker volume if they still live inside the app container (one-time)
  5. Points docker-compose.yml at the new image and pulls it
  6. Stops the app container and runs the migrations with the new image before it starts
  7. Starts the stack (docker compose up -d)
  8. Waits for the health endpoint, then checks that migrations are at head

On an Enterprise installation, update logs in to the Enterprise registry with your license, backs up the database, runs migrations with the new images before they start, and waits for the API to report Enterprise mode.

backup

Create a backup archive of the database, your .env file and uploaded content.

npx learnhouse backup
Argument / flagDescription
[archive]Path to a backup archive, used with --restore
--restoreRestore from a backup archive instead of creating one
-y, --yesRestore without asking for confirmation

Backups are saved to <installDir>/backups/learnhouse-backup-<timestamp>.tar.gz. The archive contains:

  • database.sql: a pg_dump of the database
  • .env: a copy of your environment file
  • content.tar: uploaded files from the app container (skipped when content is stored in S3)
  • backup.json: CLI version, deployment ID, edition and creation date

The backups/ directory and the archive are readable only by your user, because they contain every secret in .env.

In a terminal, backup asks whether to create or restore a backup. Without a terminal (cron, CI) it creates one without asking. backup only works with the in-container database; for an external database use your provider's backup tools.

restore

Restore a backup. This overwrites the current database.

npx learnhouse restore backups/learnhouse-backup-<timestamp>.tar.gz
Argument / flagDescription
<archive>A .tar.gz archive from backup, a .sql.gz dump written by update, or a plain .sql dump
-y, --yesDon't ask for confirmation. Required when there is no terminal.

npx learnhouse backup --restore <archive> does the same thing.

What restore does:

  1. Stops the services that hold database connections (the app container)
  2. Replaces the public schema in one transaction. If any statement fails, the transaction rolls back and the database is left unchanged.
  3. In a terminal, offers to restore the .env file from the archive (it warns when the backup came from another deployment)
  4. Starts the stopped services again and restores uploaded content from content.tar

doctor

Run diagnostics to find issues.

npx learnhouse doctor

Checks:

  • Docker installation and daemon status
  • Container state and restart counts (warns after more than 3 restarts)
  • Whether the HTTP port is free or used by LearnHouse
  • DNS resolution (for non-localhost domains)
  • Free disk space (warns below 1 GB) and Docker disk usage
  • Errors in the last 50 log lines of each running container
  • .env validation: required variables present and secrets at least 8 characters long
  • The image and image ID each container runs

doctor still runs the Docker checks when no installation is found. It exits with code 1 when a check fails.

deployments

View all LearnHouse deployments on this machine or set resource limits.

npx learnhouse deployments
  • View deployments: lists every LearnHouse deployment found in Docker, with each container's status
  • Set resource limits: same as scale

scale

Set a memory limit for each service.

npx learnhouse scale

The command shows current CPU and memory usage, then asks for a limit per service (learnhouse-app, db and redis on Community; api, web, collab, db and redis on Enterprise). Use values like 512m or 1g, or leave a value empty to skip it. The limits are written to docker-compose.yml as mem_limit, and the CLI offers to restart the changed containers.

env

Interactive editor for the variables in .env, grouped by category.

npx learnhouse env

Community categories:

  • Domain & Hosting
  • Database & Redis
  • Security
  • AI
  • Email (Resend and SMTP)
  • S3 Storage
  • OAuth

Enterprise installations get their own categories: License & Images, Domain & TLS, Database, and Security.

Secret values are always masked and are entered without echo. Only the variables you change are rewritten; the rest of the file stays as it was. When you change HTTP_PORT, learnhouse.config.json is updated to match. At the end the CLI offers to restart services so the change takes effect.

env edits a fixed set of variables. For anything else, such as the AI provider settings, edit .env directly and run npx learnhouse start.

shell

Open an interactive shell (/bin/sh) inside a running container.

npx learnhouse shell

The CLI lists the running containers so you can pick one.

dev

Start a local development environment. See Dev Mode for details.

npx learnhouse dev
FlagDescription
--eeEnable Enterprise Edition features (links a sibling EE checkout into apps/api/ee and apps/web/ee)
--admin-email <email>Admin email (default: [email protected])
--admin-password <password>Admin password (skips the interactive prompt)

Update notices

After a command finishes, the CLI checks npm for a newer version of itself and prints a notice if there is one. The check is skipped when the output is not a terminal, when CI is set, or when LEARNHOUSE_NO_UPDATE_CHECK or NO_UPDATE_NOTIFIER is set.

Troubleshooting

Containers restart in a loop

Run npx learnhouse doctor. It scans recent logs and reports errors. Common causes:

  • Missing required variable in .env
  • Port conflict (another process is using the HTTP port)
  • Damaged PostgreSQL volume (restore from a backup)

update migration fails

If the migrations fail, update restores the previous image in docker-compose.yml and starts the previous version again. Your pre-upgrade dump is in backups/. Check the LearnHouse releases page and the GitHub issues for your version before retrying. To run the migrations by hand, from the installation directory:

docker compose exec learnhouse-app sh -c "cd /app/api && uv run python cli.py migrate"

See Database Migrations for how the API migrates on startup.

Database unreachable after update

The database container may need a moment after startup. Wait 20 to 30 seconds and run npx learnhouse health. If health checks keep failing, run npx learnhouse logs to see the PostgreSQL logs.

Docker is not on your PATH, or you use a compatible CLI

Set LEARNHOUSE_DOCKER_BIN to the Docker executable the CLI should call, for example an absolute path or another Docker-compatible CLI. See CLI Environment Variables.