Skip to content

Auto-port 5.0: Resolve all localhost addresses without querying DNS servers#16819

Merged
normanmaurer merged 1 commit into
5.0from
auto-port-pr-16749-to-5.0
May 18, 2026
Merged

Auto-port 5.0: Resolve all localhost addresses without querying DNS servers#16819
normanmaurer merged 1 commit into
5.0from
auto-port-pr-16749-to-5.0

Conversation

@netty-project-bot
Copy link
Copy Markdown
Contributor

Auto-port of #16749 to 5.0
Cherry-picked commit: a6aeb6d


Motivation:

According to RFC 6761, all domains within .localhost. should be resolved to the loopback address without querying DNS servers. This is useful e.g. when you have multiple web servers behind a local reverse proxy and you want to route the requests based on the hostname. Previously, netty would only resolve hostnames specified in the hosts file (or localhost and the machine hostname on windows) without querying DNS servers.

Modifications:

  • localhost and all domains within .localhost. are now directly resolved to the loopback address
  • Replaced isLocalWindowsHost with isLocalHostAddress
  • Replaced LOCALHOST_ADDRESS constant with getLocalHostAddress method to correctly return the correct loopback address based on resolvedAddressTypes
  • Added test that covers all combinations of DnsNameResolverChannelStrategy, ResolvedAddressTypes and various localhost hostnames

Result:

Localhost hostnames are now resolved directly to the loopback address without querying a DNS server. Overriding them in the hosts file is still possible.

Fixes #16744

Motivation:

According to RFC 6761, all domains within .localhost. should be resolved
to the loopback address without querying DNS servers. This is useful
e.g. when you have multiple web servers behind a local reverse proxy and
you want to route the requests based on the hostname. Previously, netty
would only resolve hostnames specified in the hosts file (or localhost
and the machine hostname on windows) without querying DNS servers.

Modifications:

- localhost and all domains within .localhost. are now directly resolved
to the loopback address
- Replaced isLocalWindowsHost with isLocalHostAddress
- Replaced LOCALHOST_ADDRESS constant with getLocalHostAddress method to
correctly return the correct loopback address based on
resolvedAddressTypes
- Added test that covers all combinations of
DnsNameResolverChannelStrategy, ResolvedAddressTypes and various
localhost hostnames

Result:

Localhost hostnames are now resolved directly to the loopback address
without querying a DNS server. Overriding them in the hosts file is
still possible.

Fixes #16744

---------

Co-authored-by: Norman Maurer <[email protected]>
(cherry picked from commit a6aeb6d)
@normanmaurer normanmaurer merged commit df9f928 into 5.0 May 18, 2026
20 of 23 checks passed
@normanmaurer normanmaurer deleted the auto-port-pr-16749-to-5.0 branch May 18, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants