> For the complete documentation index, see [llms.txt](https://docs.hostinger.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hostinger.com/api-reference/cli-preview.md).

# Share a Local Server

Share a web server running on your computer at a temporary public HTTPS address with hostinger preview — to show work in progress or test webhooks, with nothing uploaded.

`hostinger preview` gives a web server on your computer a temporary public `https://` address. Use it to show work in progress, or to receive webhooks while you develop. Nothing is uploaded: requests reach your server through an encrypted tunnel while the command runs, so your computer needs no public IP address and no open inbound port.

It's part of the [Hostinger CLI](https://docs.hostinger.com/api-reference/cli.md). Install it and sign in as described there.

## Start a Preview

Start your dev server as usual, then run:

```bash
hostinger preview
```

Without a port, the CLI looks for a server on the usual dev server ports: 5173, 3000, 4321, 8080, 8000, 5000, 4200, and 8888 (Jupyter's port, shared with a warning). If it finds more than one, it asks which to share. When the Preview is ready, it prints the address:

```
Found a server at http://127.0.0.1:5173

Preview ready: https://7f3c9a1e0b2d8c4f9e6a5b3d1c0f2e4a.hostingerpreview.com

  Forwarding to  http://127.0.0.1:5173
  Expires        2026-11-06 14:05 EET (in 23h59m)
  Linked to your Hostinger account

Anyone with the URL can reach this server, including debug consoles and dev tools.
Press Ctrl+C to stop.
```

If the Preview takes more than a few seconds to answer, the CLI prints the address early, notes that it may answer `530` for a few seconds, and prints **Preview ready.** once it answers.

The address is random, and the Preview runs until you press **Ctrl+C** or it expires. Each run gets a new address — there's no way to keep or choose one.

> **Warning:** Anyone with the address can open your server. Don't share a Preview of an app that holds real data or has no sign-in of its own.

## How long it lasts

A Preview lasts 24 hours. To change that, pass `--ttl` with a duration from `1h` to `7d`, such as `90m`, `12h`, `3d`, or `1d12h`:

```bash
hostinger preview 3000 --ttl 3d
```

The Preview ends a few minutes before that time. The output shows when it expires.

## Choose what to share

| Command                                          | What it shares                                                             |
| ------------------------------------------------ | -------------------------------------------------------------------------- |
| `hostinger preview 3000`                         | `http://localhost:3000`                                                    |
| `hostinger preview --url https://localhost:8443` | Any `http` or `https` origin, including a server elsewhere on your network |
| `hostinger preview 8080 --host-header shop.test` | Sends `Host: shop.test` to the server instead of the Preview's host name   |

Requests reach your server with the Preview's host name in the `Host` header. Dev servers that only answer to their own names refuse those requests until you allow `.hostingerpreview.com`. In Vite, add it to `server.allowedHosts` in `vite.config.js`:

```js
export default {
  server: {
    allowedHosts: ['.hostingerpreview.com'],
  },
}
```

`--host-header` replaces the `Host` header instead, for servers that route by name.

> **Warning:** Don't pass `localhost` or an IP address to `--host-header`. It skips the dev server's host check, and its debug consoles become public.

The ports of databases, remote shells, debuggers, and similar services on your computer are never shared, even when you name them — for example 22 (SSH), 3306 (MySQL), 5432 (PostgreSQL), 6379 (Redis), and 9229 (Node.js inspector).

## What visitors see

A browser that opens a Preview first gets a Hostinger page warning that the site is temporary and that it shouldn't be trusted with passwords or payment details. After **Continue to the site**, that browser doesn't see the page again for 24 hours.

Webhooks, API clients, and tools such as `curl` never see the warning page. To skip it from a browser-like client, send the request header `Hcdn-Skip-Browser-Warning: 1`.

A few things behave differently from a normal website:

* **Cookies** — cookies scoped to a single host work. Cookies set with a `Domain` attribute are dropped, so they can't reach other Previews.
* **Service workers** — a Preview can't register one.
* **Request rate** — a Preview that receives a very high number of requests in a short time answers `429 Too Many Requests` for a few seconds.

## Sign-in

A Preview needs a Hostinger account. Sign in with `hostinger auth login`, or set an API token. If you aren't signed in, `hostinger preview` opens your browser to sign in when it runs in a terminal. Elsewhere, and with `--json`, it exits with code `77` instead.

The Preview is linked to that account, and the output says **Linked to your Hostinger account**.

## Use it from scripts

`--json` prints one JSON object per line on standard output, so a script can wait for the address:

| Event       | When                                                                                                                  | Fields                                                                     |
| ----------- | --------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| `ready`     | The Preview has its address                                                                                           | `url`, `expires_at`, `reachable` (`false` while it may still answer `530`) |
| `reachable` | A Preview reported with `"reachable": false` starts to answer                                                         | —                                                                          |
| `paused`    | The Preview is offline for a while — for example, too many Previews from your network — and the CLI retries by itself | `reason`, `retry_after` (seconds)                                          |
| `ended`     | The Preview stopped                                                                                                   | `reason`, plus `message` when it failed                                    |

```bash
hostinger preview 3000 --json | jq -r 'select(.event == "ready") | .url'
```

Logs go to standard error. The exit code says how the Preview ended:

| Code | Meaning                                                          |
| ---- | ---------------------------------------------------------------- |
| `0`  | Stopped with **Ctrl+C**, or expired.                             |
| `1`  | Any other failure, such as a blocked network.                    |
| `2`  | Invalid input — an unknown flag, or a port that can't be shared. |
| `77` | No account is signed in, or the service refused the account.     |
| `78` | The Preview was taken down.                                      |

## Troubleshooting

* **`outbound TCP 7844 is blocked on this network`** — the CLI connects out on port 7844, and falls back to 443. Allow outbound connections on at least one of them, or try another network.
* **`no server found on ports …`** — your dev server isn't running, or it uses another port. Pass the port: `hostinger preview 8081`.
* **`too many Previews from your network; retrying at …`** — the CLI waits and retries by itself. Leave it running.
* **The page shows "Invalid Host header" or a blocked-host error** — allow `.hostingerpreview.com` in your dev server, as described in [Choose what to share](#choose-what-to-share).
* **`this Preview was taken down`** — the Preview was reported and removed. Report misuse of someone else's Preview at [hostinger.com/report-abuse](https://www.hostinger.com/report-abuse).

***

*Last updated: November 20, 2026*
