starlette icon indicating copy to clipboard operation
starlette copied to clipboard

TrustedHostMiddleware rejects requests from IPv6 hosts

Open Kludex opened this issue 3 months ago • 1 comments

When my app runs behind an IPv6 address and I configure TrustedHostMiddleware with allowed_hosts, requests coming from bracketed IPv6 hosts like [::1]:8000 get rejected with 400 Invalid host header even though the host is in the allowed list. It looks like the middleware does not parse the brackets/port for IPv6 correctly.

Kludex avatar Aug 22 '26 12:08 Kludex

Thanks for the report — this is a duplicate of #3357. That issue already describes TrustedHostMiddleware rejecting bracketed IPv6 hosts/ports, so discussion and fixes are being tracked there.

pgtask-cloud avatar Aug 22 '26 12:08 pgtask-cloud