Horizon

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/cli

The package adds two binaries, hrzn and horizon. They run the same CLI. This reference uses hrzn.

Global options

These work on every command.

OptionAliasDefaultDescription
--version-vnonePrint the installed CLI version.
--help-hnonePrint 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:

Output
HORIZON: Horizon 0.18.1 is available, you are on 0.18.0. Update with: npm install --global @hrzn/cli

When the latest version has a higher major number than yours, the CLI stops with exit code 1 and prints:

Output
HORIZON: Horizon 0.18.0 is no longer supported. Install 1.0.0 to continue: npm install --global @hrzn/cli

If 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.

ArgumentDescription
<account-id>Your account ID. Required.

The command has no options.

Output
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:

WhenThe CLI prints
You are already signed inYou are already signed in. Run hrzn logout first to switch accounts.
The account ID doesn't existNo Horizon account has the account ID "<account-id>". Sign up at https://hrzn.run/login.
The approval link expiresThe approval link expired. Run hrzn login <account-id> again.
You decline in the browserThe sign-in was declined in your browser.

hrzn logout

Sign out of your Horizon account. The command clears the stored credentials.

hrzn logout

The command has no arguments or options.

Output
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>
ArgumentDescription
<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.
OptionAliasDefaultDescription
--subdomain <subdomain>-sA random subdomain that changes every runA 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:

Output
Give the local URL to expose, for example: hrzn tunnel http://localhost:3000

When the tunnel connects, the terminal prints a header, a blank line, then one line per request.

Output
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  /socket

A 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

WhenThe CLI prints
The connection to Horizon dropsConnection lost. Reconnecting…
Horizon is unreachableCannot reach Horizon. Retrying…
The connection comes backReconnected.
Your local server refuses the connectionCould not connect to your local server at http://localhost:3000. Is it running?
Horizon closes the tunnelThe tunnel was closed. Run hrzn tunnel http://localhost:3000 again.
The same subdomain starts in a second terminalThis 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.

VariableDefaultDescription
DO_NOT_TRACKunsetSet to any non-empty value to turn off usage analytics.
HORIZON_TELEMETRY_DISABLEDunsetSet 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.

On this page