> ## Documentation Index
> Fetch the complete documentation index at: https://docs.boat.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How public URLs work

> How boat routes a public HTTPS request to a port in your sandbox, apps that listen on localhost, and the Vite 'host not allowed' error.

## What `host <port>` does

1. The sandbox asks the boat backend for a stable public route for that sandbox and port.
2. The backend registers a subdomain. It uses the current machine address of the sandbox and the port that you asked for.
3. boat prints the URL.

The hostname is the sandbox subdomain plus the port.

```text theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
https://<sandbox-subdomain>-<port>.on.boat.dev
```

## How a request reaches your app

1. boat terminates TLS for `on.boat.dev`.
2. boat proxies the request to the sandbox, on the port that you exposed.
3. Your app answers from inside the sandbox.

The public HTTPS route sits in front of your app. It connects to the sandbox address, not to the loopback interface. An app on `0.0.0.0` answers there directly.

## Services that listen on localhost

An app on `localhost`, `127.0.0.1` or `::1` only does not answer on the sandbox address. Declare it with `--localhost`:

```text theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
browser -> route -> sandbox address:<port> -> Boat relay -> 127.0.0.1:<port> or [::1]:<port>
```

* The sandbox relays the port to `127.0.0.1`, then to `::1` if nothing answers on `127.0.0.1`.
* The relay passes raw TCP, so HTTP, WebSockets and hot reload work.
* The relay stays on after a stop, a resume and an agent upgrade. A fork does not keep it.
* Each relayed port has its own small relay process. `lsof -ti :<port> | xargs kill -9` or `npx kill-port <port>` kills that relay too. The rest of the sandbox keeps working, and the relay starts again in about one second.
* Every host call sets the value again. Hosting the same port without `--localhost` turns the relay off and closes its open connections.
* `host hide <port>` and making the port private also turn the relay off.
* Do not use `--localhost` for an app on `0.0.0.0`. The relay then holds the port, and the app cannot start again on it.

```bash theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
npm run dev -- --port 5173          # Vite listens on localhost by default
host 5173 --localhost
```

## "Blocked request" or "host not allowed"

Some dev servers refuse requests for host names that they do not know. Vite shows `Blocked request. This host is not allowed.` Allow the boat domain:

```js vite.config.js theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
export default {
  server: { allowedHosts: [".on.boat.dev"] },
};
```

## Credentials

The `host` command in the sandbox uses `ASCII_TOKEN`. This token can only host ports of its own sandbox. boat registers the route. Read [Security for platforms](https://docs.boat.dev/security.md#boat-credentials-inside-a-sandbox).

## The `on.ascii.dev` domain

> [!NOTE]
>
> boat serves every hosted address under `on.boat.dev` and `on.ascii.dev`, with the same label. `on.ascii.dev` is the name from before the rename. So `SUBDOMAIN-3000.on.ascii.dev` and `SUBDOMAIN-3000.on.boat.dev` are the same route. Links that you shared as `on.ascii.dev` keep working until boat retires that suffix. Publish `on.boat.dev` links.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.