CLI reference
hrzn CLI reference. Every command, option and environment variable of the Horizon command line tool.
Look up every hrzn command, option and environment variable. For a first tunnel, start with Getting started.
Install
npm install -g @hrzn/cliThe package adds two binaries, hrzn and horizon. They run the same CLI. This reference uses hrzn.
Global options
These work on every command.
| Option | Alias | Default | Description |
|---|---|---|---|
--version | -v | none | Print the installed CLI version. |
--help | -h | none | Print usage for the CLI, or for one command when you put it after the command name. |
Before each command runs, the CLI checks the latest published version. When a newer version exists, it prints a warning and carries on:
HORIZON: Horizon 0.18.1 is available, you are on 0.18.0. Update with: npm install --global @hrzn/cliWhen the latest version has a higher major number than yours, the CLI stops with exit code 1 and prints:
HORIZON: Horizon 0.18.0 is no longer supported. Install 1.0.0 to continue: npm install --global @hrzn/cliIf the check can't reach Horizon, the command runs without it.
hrzn login
Sign in to your Horizon account. The command prints an approval link, waits while you approve it in your browser, then stores your credentials in .hrznrc in your home folder (_hrznrc on Windows).
hrzn login <account-id>Your dashboard shows the command with your account ID filled in.
| Argument | Description |
|---|---|
<account-id> | Your account ID. Required. |
The command has no options.
HORIZON: Approve the sign-in in your browser: <approval-link>
HORIZON: Signed in. Run hrzn tunnel http://localhost:3000 to start a tunnel.Other outcomes, each with exit code 1 except the first:
| When | The CLI prints |
|---|---|
| You are already signed in | You are already signed in. Run hrzn logout first to switch accounts. |
| The account ID doesn't exist | No Horizon account has the account ID "<account-id>". Sign up at https://hrzn.run/login. |
| The approval link expires | The approval link expired. Run hrzn login <account-id> again. |
| You decline in the browser | The sign-in was declined in your browser. |
hrzn logout
Sign out of your Horizon account. The command clears the stored credentials.
hrzn logoutThe command has no arguments or options.
HORIZON: Signed out.hrzn tunnel
Put a local server on a public HTTPS URL. The command stays running and prints each request. Press Ctrl+C to stop it.
hrzn tunnel <url>| Argument | Description |
|---|---|
<url> | The local URL to expose, with its protocol and an optional port. For example http://localhost:3000 or http://192.168.0.1:5173. Required. |
| Option | Alias | Default | Description |
|---|---|---|---|
--subdomain <subdomain> | -s | A random subdomain that changes every run | A subdomain you reserved. Your tunnel opens at https://<subdomain>.hrzn.run. |
Run hrzn login first. Without a sign-in, the command prints You are not signed in. Run hrzn login <account-id>. and exits with code 1.
If <url> isn't a valid URL, the command prints this and exits:
Give the local URL to expose, for example: hrzn tunnel http://localhost:3000When the tunnel connects, the terminal prints a header, a blank line, then one line per request.
HORIZON: Tunnel connected
URL https://my-app.hrzn.run
Forwarding http://localhost:3000
Request log <request-log-link>
POST 200 /api/webhooks/stripe
GET 200 /api/webhooks/x?crc_token=abc
WS 101 /socketA request line shows the method, the status your local server returned and the path with its query string. A WebSocket upgrade shows WS. The status is green for 2xx, amber for 3xx and 4xx, and red for 5xx. When your local server can't be reached, the status reads ERR.
The CLI sets the Host header to your local address. The public host arrives in X-Forwarded-Host.
Status messages
| When | The CLI prints |
|---|---|
| The connection to Horizon drops | Connection lost. Reconnecting… |
| Horizon is unreachable | Cannot reach Horizon. Retrying… |
| The connection comes back | Reconnected. |
| Your local server refuses the connection | Could not connect to your local server at http://localhost:3000. Is it running? |
| Horizon closes the tunnel | The tunnel was closed. Run hrzn tunnel http://localhost:3000 again. |
| The same subdomain starts in a second terminal | This tunnel was started in another terminal, so this one stopped. |
The first terminal exits with code 0 when another terminal takes the subdomain. It exits with code 1 when Horizon closes the tunnel for any other reason.
Environment variables
The CLI reads these variables from your shell and from a .env file in the folder where you run the command.
| Variable | Default | Description |
|---|---|---|
DO_NOT_TRACK | unset | Set to any non-empty value to turn off usage analytics. |
HORIZON_TELEMETRY_DISABLED | unset | Set to any non-empty value to turn off usage analytics. |
The CLI also reads other variables, but only when run from the Horizon source tree. They aren't for general use and this page leaves them out.