Skip to content

Fixed hostname autodetection - resolvable#26037

Draft
dmatej wants to merge 9 commits into
eclipse-ee4j:mainfrom
dmatej:masterpassword
Draft

Fixed hostname autodetection - resolvable#26037
dmatej wants to merge 9 commits into
eclipse-ee4j:mainfrom
dmatej:masterpassword

Conversation

@dmatej

@dmatej dmatej commented May 22, 2026

Copy link
Copy Markdown
Contributor

All previous versions were good in some scenarios and wrong in others. In #25972 I assumed that computer's host name is usually resolvable by default, localhost is resolvable always to loopback ip address, however all these assumptions may be wrong.

Unfortunately Java doesn't have any tool to just get the name. On Linux based systems there's the hostname program - in the past were used HOST and HOSTNAME environment options set by shell, however modern Linux versions don't set them any more. On Windows there's the COMPUTERNAME environment option.

If the host name is resolvable on this machine - it doesn't mean it is resolvable from the outside. That means there should be a way user could explicitly set the host name as any internal autodetection doesn't have all information.

Special Situations

I have found the GH Actions is a good reproducer of several scenarios which are OS dependent, shell dependent, DNS dependent, and even dependent on order of actions. I will slowly collect some informations.

  • hostname is often just the name of the computer, short without dots. When you list network interfaces, list their host names, there may be full host name, for example ...
  • Ubuntu based GitHub Actions use
    • hostname: runnervm3jyl0
    • list: runnervm3jyl0.fwbxogqxw2hu1gnhcu514ce0ub.bx.internal.cloudapp.net, localhost
  • While Windows based GitHub Actions use
    • hostname: runnervmlu3mh
    • list: runnervmlu3mh.jmhn0wqfkjtehmf45kke2dh3lh.bx.internal.cloudapp.net - no localhost here!

Why Avoid getLocalHost().getHostName()?

  • Claude's question and answer, I asked how to get the information in Java.
  • This does DNS resolution — slow, may fail, may return wrong name:
InetAddress.getLocalHost().getHostName();
  • This also resolves
InetAddress.getLocalHost().getCanonicalHostName();

It can cause issues when:

  • Running in containers (Docker/Kubernetes)
  • No DNS is configured
  • Hostname isn't registered in DNS
  • You need the raw OS hostname, not the DNS name

--- end of Claude's citation.

I have found yet another problem in docker - network services sometimes start bit later, so the DNS resolution may change.

We Don't Use the Host Name just for Networking

  • We use it also as an identifier. That may cause problems, because the host name may change. We should probably warn user to avoid host name changes OR to recreate whole domain and its nodes.

@dmatej dmatej added this to the 8.0.3 milestone May 22, 2026
@dmatej dmatej force-pushed the masterpassword branch 5 times, most recently from 4c1d084 to 2b52bdb Compare May 25, 2026 14:59
@dmatej dmatej changed the title Fixed masterpassword issue and changed hostname autodetection Fixed hostname autodetection - resolvable Jun 4, 2026
@dmatej dmatej force-pushed the masterpassword branch 5 times, most recently from 9a6e663 to 0edb7c3 Compare June 4, 2026 21:59
@dmatej dmatej modified the milestones: 8.0.3, 8.0.4 Jun 5, 2026
dmatej added 9 commits June 10, 2026 00:00
- was added in d362b30

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
- Does not ignore hosts without dots but prefers those which have dots
- localhost and loopback is a backup

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
- it is not guaranteed that the local host name is resolvable by DNS
- but it should be in nearly all cases we use it

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JMX Startup failed in docker

1 participant