Install
lh needs Python 3.11 or newer. On macOS or Linux one line installs it, and running it again updates it:
curl -fsSL https://api.localhost.co.zw/cli/install.sh | sh
lh --version # lh 0.1.0
It uses pipx or uv if you have one, and otherwise its own virtual environment in ~/.local/share/lh, with the command linked into ~/.local/bin. Nothing is installed system-wide. Prefer to do it yourself? It's on PyPI as localhost-cli:
pipx install localhost-cli # update: pipx upgrade localhost-cli
uv tool install localhost-cli
py -m pip install localhost-cli # Windows
Plain pip install into the system Python is refused on recent macOS (Homebrew), Debian and Ubuntu; use one of the ways above (on Windows, or inside a virtualenv you manage, pip is fine). The same package is also served from here: pipx install https://api.localhost.co.zw/cli/localhost_cli-0.1.0-py3-none-any.whl, or the index pip install --index-url https://api.localhost.co.zw/cli/simple/ localhost-cli.
Sign in
Make a key under API keys; it needs the Sites and apps permission for sites, and whatever else you'll use it for. lh login asks for it with the input hidden, checks it and stores it in ~/.config/localhost/credentials.json, readable by you alone.
lh login
lh whoami
lh logout
In CI, set LH_API_KEY instead and nothing is stored.
Settings
| Variable | Default | Purpose |
| LH_API_KEY | none | The API key to use, instead of the stored one. |
| LH_CLIENT | none | Partners: the client account to act in, the same as --client. |
| LH_API_URL | https://api.localhost.co.zw | Where the API is. |
| LH_API_HOST | none | Send this Host header (development only, when every host answers on one address). |
Options before the command
- --client SLUG
- partners: act inside this client's account (or set LH_CLIENT)
Commands
Signing in
lh login [options]
Sign in with an API key
- --key KEY
- The API key (otherwise you are prompted; avoid this on shared machines)
lh logout
Forget the stored API key
lh whoami
Show the account you are signed in to
Sites and apps
lh create <slug> [options]
Create and start a site, from a repository or an image
Use one of --repo or --image.
- <slug>
- The site's name
- --repo REPO
- Repository to build and deploy on every push: you/shop or an https:// address
- --image IMAGE
- Container image, e.g. nginx:alpine
- --branch BRANCH
- Branch to deploy (with --repo; default main)default main
- --dir DIR
- Folder inside the repository that holds the app (with --repo)
- --port PORT
- Port the app listens on (with --image; default 80)default 80
- --size SIZE
- Plan size (default S) One of XS, S, M, L.default S
- --no-follow
- Don't wait for the first build
lh deploy <slug> [options]
Build and deploy the branch (or a commit), or switch to an image
- <slug>
- The site's name
- --image IMAGE
- Run this container image instead of building
- --ref REF
- Branch or commit to build (default: the site's branch)
- --tag TAG
- Tag to build and release (for sites that deploy on tags)
- --no-follow
- Return straight away instead of showing the build log
lh start <slug>
Start a site
- <slug>
- The site's name
lh stop <slug>
Stop a site
- <slug>
- The site's name
lh logs <slug> [options]
Show recent log lines
- <slug>
- The site's name
- --tail TAIL
- Number of lines (default 100)default 100
lh open <slug> [options]
Open a site in your browser
- <slug>
- The site's name
- --print
- Only print the address
Git deploys
lh connect <slug> <repo> [options]
Deploy a site from a repository from now on
- <slug>
- The site's name
- <repo>
- You/shop or an https:// address
- --branch BRANCH
- Branch to deploy (default main)default main
- --dir DIR
- Folder inside the repository that holds the app
- --tags PATTERN
- Deploy only tags matching PATTERN (e.g. 'v*') instead of every push
- --previews / --no-previews
- A preview site for every pull request
lh builds <slug>
List a site's builds
- <slug>
- The site's name
lh previews <slug>
List a site's pull-request previews
- <slug>
- The site's name
lh rollback <slug> [options]
Put the previous live build back
- <slug>
- The site's name
- --to TO
- Build number to go back to (default: the one before the live build)
- --no-follow
- Return straight away
Settings (environment variables)
lh env [slug] [options]
List a site's settings (environment variables), or --all for shared ones
- <slug>
- The site's name optional
- --all
- The settings shared by all your sites
lh env-set [slug] <setting> [options]
Add or change a setting: lh env-set shop NAME=value (NAME alone asks for the value)
- <slug>
- The site's name optional
- <setting>
- NAME=value, or NAME to be asked for the value
- --all
- The settings shared by all your sites
- --secret / --no-secret
- Hide the value once saved (default: guessed from the name)
- --build / --no-build
- Also give it to Git builds while building
- --live-only / --no-live-only
- Keep it out of pull-request previews
- --only SITE
- With --all: only these sites (repeat)
lh env-rm [slug] <key> [options]
Remove a setting
- <slug>
- The site's name optional
- <key>
- The setting's name
- --all
- The settings shared by all your sites
lh.toml
lh init [path] [options]
Write an lh.toml for this folder from what we detect
- <path>
- The app's folder (default: here)default . optional
- --force
- Replace an lh.toml that is already there
lh check [names]
Check whether names are free and your price, or (no names) this folder's lh.toml
- <names>
- E.g. mukoko.co.zw mukoko.com; or nothing, lh.toml or a folder to check lh.toml optional
Names
lh domains
List your names
lh register <name> [options]
Register a name, paid from the wallet
- <name>
- --ns HOST
- A nameserver (repeat; default: ours)
- --no-auto-renew
- Don't renew automatically
lh renew <name> [options]
Renew a name ahead of time, paid from the wallet
- <name>
- --years YEARS
- 1 to 5 (default 1)default 1
Partners
lh clients
Partners: list your clients
lh add-client <name> [options]
Partners: add a client account you manage
- <name>
- --kind KIND
- One of business, personal.default business
lh fund <id> <amount> [options]
Partners: move money from your wallet to a client's
- <id>
- The client's ID from `lh clients`
- <amount>
- USD, e.g. 20 or 12.50
- --note NOTE
- Shown on the client's wallet
lh book [options]
Partners: every name across your clients
- --expiring DAYS
- Only names expiring within DAYS
lh bulk <action> <names> [options]
Partners: renew, lock or re-point many names at once
- <action>
- One of renew, auto_renew_on, auto_renew_off, lock, unlock, nameservers.
- <names>
- --ns HOST
- Nameservers (with the nameservers action; repeat)
- --pay-from PAY_FROM
- Who pays for renewals (default: you) One of partner, client.default partner
Exit codes
Normal output goes to stdout, so lh logs shop | grep error works. Errors are one line on stderr, prefixed lh:, with an exit code your scripts can branch on.
| Code | Meaning |
| 0 | Success. |
| 1 | Something else failed, including a server error or a build that did not go live. |
| 2 | Bad command line (usage). |
| 3 | Not signed in, or the key was not accepted. |
| 4 | Site or name not found (also what you get for someone else's). |
| 5 | Could not reach the service, or it timed out. |
| 6 | Refused: missing permission, name taken, or invalid input. |
| 130 | Interrupted with Ctrl-C. |
Against the local development stack
export LH_API_URL=http://127.0.0.1:8080
export LH_API_HOST=api.lh.localhost:8080
lh login --key lh_…