prestodb/presto · error · ProxyException

Request to remote Presto server failed

Error message

Request to remote Presto server failed

What it means

ProxyResponseHandler.handleException is the generic failure path for any Exception raised while executing the request against the remote Presto server. It wraps the cause in a ProxyException with the fixed message 'Request to remote Presto server failed'. It signals a transport-level failure, not an HTTP error status.

Source

Thrown at presto-proxy/src/main/java/com/facebook/presto/proxy/ProxyResponseHandler.java:42

import java.io.IOException;

import static com.facebook.airlift.http.client.HttpStatus.NO_CONTENT;
import static com.facebook.airlift.http.client.HttpStatus.OK;
import static com.google.common.io.ByteStreams.toByteArray;
import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
import static java.lang.String.format;
import static java.nio.charset.StandardCharsets.US_ASCII;
import static java.util.Objects.requireNonNull;

public class ProxyResponseHandler
        implements ResponseHandler<ProxyResponse, RuntimeException>
{
    private static final MediaType MEDIA_TYPE_JSON = MediaType.create("application", "json");

    @Override
    public ProxyResponse handleException(Request request, Exception exception)
    {
        throw new ProxyException("Request to remote Presto server failed", exception);
    }

    @Override
    public ProxyResponse handle(Request request, Response response)
    {
        if (response.getStatusCode() == NO_CONTENT.code()) {
            return new ProxyResponse(response.getHeaders(), new byte[0]);
        }

        if (response.getStatusCode() != OK.code()) {
            throw new ProxyException(format("Bad status code from remote Presto server: %s: %s", response.getStatusCode(), readBody(response)));
        }

        String contentType = response.getHeader(CONTENT_TYPE);
        if (contentType == null) {
            throw new ProxyException("No Content-Type set in response from remote Presto server");
        }
        if (!MediaType.parse(contentType).is(MEDIA_TYPE_JSON)) {

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Read the wrapped cause (getCause()) for the real transport error.
  2. Verify the remote Presto server URI, DNS, and network reachability.
  3. Increase client connect/read timeouts if failures correlate with long queries.
  4. Retry with backoff; enable HTTP client connection keep-alive/pool hygiene.
Defensive patterns

Strategy: retry

Validate before calling

// preflight connectivity to the remote server
const net = require('net');
const s = net.connect(port, host);
s.on('connect', () => { console.log('reachable'); s.end(); });
s.on('error', e => console.error('unreachable:', e.message));

Try / catch

try {
  return await proxyClient.execute(req);
} catch (e) {
  if (e instanceof ProxyException && e.getCause() instanceof java.io.IOException) {
    return retryWithBackoff(req, 3); // transient transport failure
  }
  throw e;
}

Prevention

When it happens

Trigger: Any IOException/connection failure thrown by the HTTP client while calling the remote server (connect timeout, read timeout, connection reset, TLS failure) during a proxied statement/request.

Common situations: Remote coordinator overloaded or restarted mid-request; idle connection reaped by a firewall causing reset; DNS failure; misconfigured remote server URI.

Understand the failure class

Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.

Related errors


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