> Markdown version of https://tuna.am/en/docs/troubleshooting/host-not-allowed/. Documentation index: [llms.txt](https://tuna.am/en/llms.txt), full text in one file: [llms-full.txt](https://tuna.am/en/llms-full.txt). Any page is available as Markdown: append `.md` to its URL without the trailing slash.

# The app responds with "Invalid Host header" or "Blocked request"

## Symptoms

The app opens locally, but at the tunnel address you get an error from the app itself:

| App                | What you see                                                                                                                |
| ------------------ | --------------------------------------------------------------------------------------------------------------------------- |
| Vite               | `Blocked request. This host ("brave-otter-4821.a.tuna.free") is not allowed.`                                               |
| webpack-dev-server | `Invalid Host header`                                                                                                       |
| Django             | `400 Bad Request`, with `Invalid HTTP_HOST header` in the log                                                               |
| Rails              | a `Blocked hosts: brave-otter-4821.a.tuna.free` page                                                                        |
| Next.js            | the page opens, but hot reload doesn't work, and the server console warns about a request to `/_next/*` from another origin |

In the [inspector](https://tuna.am/en/docs/tunnels/inspect.md), the request reached the app, and the response came from the app, not from tuna.

## Cause

tuna passes the `Host` header to the app exactly as the visitor sent it, with the tunnel address. Dev servers accept only `localhost` by default to protect against DNS rebinding attacks, so they reject any other name.

## Fix

There are two ways. The first is simpler; the second is the right one if the app builds absolute links.

### Replace the Host header

The [`--request-header`](https://tuna.am/en/docs/tunnels/http.md#request-header) flag replaces `Host` before the request reaches the app, so the app sees the familiar `localhost`:

```shell
tuna http 5173 --request-header="host:localhost:5173"

```

The app will think it was opened at `localhost`. If it builds absolute links or redirects from `Host`, they will point to `localhost`. In that case, use the second way.

### Allow the tunnel address in the app

Allow the tuna zones: `a.2na.am` for dynamic and reserved addresses and `a.tuna.free` for the free permanent subdomain. If the tunnel runs on [your own domain](https://tuna.am/en/docs/tunnels/http.md#custom-domain), add it too. You only need this in development mode.

Vite, `vite.config.js`:

```js
export default defineConfig({
  server: {
    allowedHosts: ['.a.2na.am', '.a.tuna.free'],
  },
});

```

webpack-dev-server, `webpack.config.js`:

```js
module.exports = {
  devServer: {
    allowedHosts: ['.a.2na.am', '.a.tuna.free'],
  },
};

```

Django, `settings.py`. POST forms over HTTPS also need `CSRF_TRUSTED_ORIGINS`, otherwise Django responds with `CSRF verification failed`:

```python
ALLOWED_HOSTS = ['localhost', '.a.2na.am', '.a.tuna.free']
CSRF_TRUSTED_ORIGINS = ['https://*.a.2na.am', 'https://*.a.tuna.free']

```

Rails, `config/environments/development.rb`:

```ruby
config.hosts << ".a.2na.am"
config.hosts << ".a.tuna.free"

```

Next.js, `next.config.js`:

```js
module.exports = {
  allowedDevOrigins: ['*.a.2na.am', '*.a.tuna.free'],
};

```

Restart the dev server after the change.
