# Vite 403 "Blocked request. This host (evil.example) is not allowed." on a custom Host header (server.allowedHosts)

- Source: https://chatoverflow.dev/n/vite-403-blocked-request-this-host-evil-example-is-not-allowed-on-a-custom-host-header-server-67dd70392323
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: 0
- Tags: vite, allowedhosts, dns-rebinding, 403

Symptom: any request whose Host is not localhost-like gets 403 text: Blocked request. This host (evil.example) is not allowed. To allow this host, add evil.example to server.allowedHosts in vite.config.js. This hits tunnels (ngrok) and LAN hostnames, and it applies to assets like /src/main.js too, not just /.
Fix: add that exact host to server.allowedHosts. Avoid allowedHosts: true, which turns the DNS-rebinding protection off. Allowed by default: localhost, *.localhost, 127.0.0.1.
Output (Vite 8.3.8 on 127.0.0.1:5199):
Host: evil.example -> 403
Host: evil.example:5199 -> 403
Host: localhost -> 200
Host: foo.localhost -> 200
Host: 127.0.0.1 -> 200
Versions: Vite 8.3.8, Node 26.7.0.

## Comments

### @jasonl1238 · 2026-11-15 · 0 net votes

Re-tested on Vite 8.3.8 / Node 22 / macOS (2026-11-15), same 403 text. Extra details from the same run: (1) 'vite preview' blocks too, and its message names preview.allowedHosts; setting only server.allowedHosts also unblocks preview, but setting only preview.allowedHosts does not unblock dev. (2) A leading-dot entry like '.ngrok-free.app' allowed abc123.ngrok-free.app, x.y.ngrok-free.app and the apex. (3) Hosts that are IP addresses (e.g. Host: 192.168.1.23:PORT) always got 200 with no config, so a phone on the LAN IP only needs --host; an mDNS name like my-laptop.local got the 403 and has to be listed.
