prestodb/presto · error · ClientException

Failed to resolve host:

Error message

Failed to resolve host: 

What it means

canonicalizeServiceHostName catches UnknownHostException while resolving the service host's IP or canonical name and throws a ClientException 'Failed to resolve host: <host>'. DNS cannot resolve the Presto coordinator host, so a SPNEGO service principal cannot be constructed.

Source

Thrown at presto-client/src/main/java/com/facebook/presto/client/SpnegoHandler.java:266

    private static String canonicalizeServiceHostName(String hostName)
    {
        try {
            InetAddress address = InetAddress.getByName(hostName);
            String fullHostName;
            if ("localhost".equalsIgnoreCase(address.getHostName())) {
                fullHostName = InetAddress.getLocalHost().getCanonicalHostName();
            }
            else {
                fullHostName = address.getCanonicalHostName();
            }
            if (fullHostName.equalsIgnoreCase("localhost")) {
                throw new ClientException("Fully qualified name of localhost should not resolve to 'localhost'. System configuration error?");
            }
            return fullHostName;
        }
        catch (UnknownHostException e) {
            throw new ClientException("Failed to resolve host: " + hostName, e);
        }
    }

    private interface GssSupplier<T>
    {
        T get()
                throws GSSException;
    }

    private static <T> T doAs(Subject subject, GssSupplier<T> action)
            throws GSSException
    {
        try {
            return Subject.doAs(subject, (PrivilegedExceptionAction<T>) action::get);
        }
        catch (PrivilegedActionException e) {
            Throwable t = e.getCause();
            throwIfInstanceOf(t, GSSException.class);

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Verify the server hostname in the connection URL is spelled correctly.
  2. Test resolution: nslookup <host> / getent hosts <host>; add an /etc/hosts entry as an immediate workaround.
  3. Fix DNS server configuration or connect to the network/VPN that can resolve the cluster hosts.
  4. Use the fully qualified domain name instead of a short name.

Example fix

// before
presto --server https://presto-coordinator:8080  # UnknownHostException
// after
presto --server https://presto-coordinator.example.com:8080  # or add host to /etc/hosts
Defensive patterns

Strategy: validation

Validate before calling

try {
    InetAddress.getByName(coordinatorHost);
} catch (UnknownHostException e) {
    throw new IllegalStateException("Cannot resolve coordinator host: " + coordinatorHost);
}

Try / catch

try { ... } catch (ClientException e) { if (e.getMessage().startsWith("Failed to resolve host")) { /* fix DNS or /etc/hosts, then retry */ } throw e; }

Prevention

When it happens

Trigger: makeServicePrincipal -> canonicalizeServiceHostName with a hostName that InetAddress.getByName/getLocalHost cannot resolve (UnknownHostException).

Common situations: Coordinator hostname typo in --server URL; DNS outage; host only in local /etc/hosts but client runs elsewhere; IPv6-only resolution issues; VPN not connected.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/5f47f45752d7ff2e. Report an issue: GitHub.