prestodb/presto · critical · RuntimeException

Next URI host and port %s are different than current %s

Error message

Next URI host and port %s are different than current %s

What it means

StatementClientV1 validates that each nextUri returned by the Presto coordinator matches the host and port of the original infoUri. If the server returns a next URI pointing at a different host/port, the client treats the response as untrustworthy (a potential DNS rebinding/security issue), marks the client CLIENT_ERROR, and throws this RuntimeException, aborting the query.

Source

Thrown at presto-client/src/main/java/com/facebook/presto/client/StatementClientV1.java:445

            if (response.getStatusCode() != HTTP_UNAVAILABLE) {
                state.compareAndSet(State.RUNNING, State.CLIENT_ERROR);
                throw requestFailedException("fetching next", request, response);
            }
        }
    }

    private void validateNextUriSource(final URI nextUri, final URI infoUri)
    {
        if (!validateNextUriSource) {
            return;
        }

        if (nextUri.getHost().equals(infoUri.getHost())
                && nextUri.getPort() == infoUri.getPort()) {
            return;
        }
        state.compareAndSet(State.RUNNING, State.CLIENT_ERROR);
        throw new RuntimeException(format("Next URI host and port %s are different than current %s", nextUri.getHost(), infoUri.getHost()));
    }

    private static Map<String, List<String>> toHeaderMap(Headers headers)
    {
        ImmutableMap.Builder<String, List<String>> builder = ImmutableMap.builder();
        for (String name : headers.names()) {
            builder.put(name, ImmutableList.copyOf(headers.values(name)));
        }
        return builder.build();
    }

    private void processResponse(Headers headers, QueryResults results)
    {
        setCatalog.set(headers.get(PRESTO_SET_CATALOG));
        setSchema.set(headers.get(PRESTO_SET_SCHEMA));

        for (String setSession : headers.values(PRESTO_SET_SESSION)) {
            List<String> keyValue = SESSION_HEADER_SPLITTER.splitToList(setSession);

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Align the coordinator's advertised URI with the address clients use: set the correct host/port in config.properties/discovery URI and http-server properties so nextUri matches infoUri.
  2. Connect clients directly to the coordinator using the same hostname and port the coordinator advertises, rather than through a rewriting proxy.
  3. If a proxy is required, configure it to preserve the original Host header and not rewrite Location/next URIs.
  4. Verify DNS so the client-resolved host and port equal those embedded in nextUri.

Example fix

// before
StatementClient client = StatementClientFactory.create(/* via proxy at presto-lb.example.com:8080 */);
// after
StatementClient client = StatementClientFactory.create(
    new Session().withServer(new HostAddress("coordinator.internal.example.com", 8081)));
Defensive patterns

Strategy: validation

Validate before calling

// client-side pre-check of server-advertised URI
if (!nextUri.getHost().equals(infoUri.getHost()) || nextUri.getPort() != infoUri.getPort()) {
    throw new IllegalStateException("Server nextUri host/port differs from infoUri: " + nextUri);
}

Type guard

boolean isSameHostAndPort(URI next, URI info) {
    return next.getHost() != null && next.getHost().equals(info.getHost())
        && next.getPort() == info.getPort();
}

Prevention

When it happens

Trigger: Calling StatementClientV1.execute/advance when the coordinator returns a nextUri whose host or port differs from the infoUri host/port — e.g. the server advertises an external hostname (or different port) than the one the client used to connect, behind a proxy/load balancer that rewrites URIs, or after a server config change of http-server.http.port or discovery URI.

Common situations: Connecting to Presto via a load balancer or ingress that redirects to the coordinator's own advertised address; cluster misconfiguration where the coordinator's internal hostname differs from the address clients use; using a different port for the next URI (e.g. https vs http port misconfiguration); DNS entries resolving to different names.

Related errors


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