static private String getPreferredHostName() {
        Optional<String> vespaHostEnv = Optional.ofNullable(System.getenv("VESPA_HOSTNAME"));
        if (vespaHostEnv.isPresent() && ! vespaHostEnv.get().trim().isEmpty()) {
            return vespaHostEnv.get().trim();
        }
        return "localhost";
    }
Return a public and fully qualified hostname for localhost that
resolves to an IP address on a network interface.

@return the preferred name of localhost
vespajlib/src/main/java/com/yahoo/net/HostName.java