{"record":{"id":"5bc101ecdfd41fb1","repo":"prestodb/presto","slug":"next-uri-host-and-port-s-are-different-than-curre","errorCode":null,"errorMessage":"Next URI host and port %s are different than current %s","messagePattern":"Next URI host and port (.+?) are different than current (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"presto-client/src/main/java/com/facebook/presto/client/StatementClientV1.java","lineNumber":445,"sourceCode":"            if (response.getStatusCode() != HTTP_UNAVAILABLE) {\n                state.compareAndSet(State.RUNNING, State.CLIENT_ERROR);\n                throw requestFailedException(\"fetching next\", request, response);\n            }\n        }\n    }\n\n    private void validateNextUriSource(final URI nextUri, final URI infoUri)\n    {\n        if (!validateNextUriSource) {\n            return;\n        }\n\n        if (nextUri.getHost().equals(infoUri.getHost())\n                && nextUri.getPort() == infoUri.getPort()) {\n            return;\n        }\n        state.compareAndSet(State.RUNNING, State.CLIENT_ERROR);\n        throw new RuntimeException(format(\"Next URI host and port %s are different than current %s\", nextUri.getHost(), infoUri.getHost()));\n    }\n\n    private static Map<String, List<String>> toHeaderMap(Headers headers)\n    {\n        ImmutableMap.Builder<String, List<String>> builder = ImmutableMap.builder();\n        for (String name : headers.names()) {\n            builder.put(name, ImmutableList.copyOf(headers.values(name)));\n        }\n        return builder.build();\n    }\n\n    private void processResponse(Headers headers, QueryResults results)\n    {\n        setCatalog.set(headers.get(PRESTO_SET_CATALOG));\n        setSchema.set(headers.get(PRESTO_SET_SCHEMA));\n\n        for (String setSession : headers.values(PRESTO_SET_SESSION)) {\n            List<String> keyValue = SESSION_HEADER_SPLITTER.splitToList(setSession);","sourceCodeStart":427,"sourceCodeEnd":463,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-client/src/main/java/com/facebook/presto/client/StatementClientV1.java#L427-L463","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","Connect clients directly to the coordinator using the same hostname and port the coordinator advertises, rather than through a rewriting proxy.","If a proxy is required, configure it to preserve the original Host header and not rewrite Location/next URIs.","Verify DNS so the client-resolved host and port equal those embedded in nextUri."],"exampleFix":"// before\nStatementClient client = StatementClientFactory.create(/* via proxy at presto-lb.example.com:8080 */);\n// after\nStatementClient client = StatementClientFactory.create(\n    new Session().withServer(new HostAddress(\"coordinator.internal.example.com\", 8081)));","handlingStrategy":"validation","validationCode":"// client-side pre-check of server-advertised URI\nif (!nextUri.getHost().equals(infoUri.getHost()) || nextUri.getPort() != infoUri.getPort()) {\n    throw new IllegalStateException(\"Server nextUri host/port differs from infoUri: \" + nextUri);\n}","typeGuard":"boolean isSameHostAndPort(URI next, URI info) {\n    return next.getHost() != null && next.getHost().equals(info.getHost())\n        && next.getPort() == info.getPort();\n}","tryCatchPattern":null,"preventionTips":["Connect using the same hostname/port the coordinator advertises in nextUri.","Avoid proxies that rewrite Host headers or redirect URIs; use DNS or client-side routing instead.","Keep config.properties (discovery URI, http-server port) consistent with external-facing addresses.","Test query execution through any LB/proxy before production to catch rewritten next URIs."],"tags":["network","security","uri-mismatch","presto-client"],"backgroundTag":"uri-host-mismatch","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}