prestodb/presto · error · ProxyException

Failed reading response from remote Presto server

Error message

Failed reading response from remote Presto server

What it means

The response passed status and Content-Type checks, but reading its body stream into bytes threw IOException. The proxy wraps this in a ProxyException with 'Failed reading response from remote Presto server'. This is a mid-body transport failure, not a parse error.

Source

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

        }

        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)) {
            throw new ProxyException("Bad Content-Type from remote Presto server:" + contentType);
        }

        try {
            return new ProxyResponse(response.getHeaders(), toByteArray(response.getInputStream()));
        }
        catch (IOException e) {
            throw new ProxyException("Failed reading response from remote Presto server", e);
        }
    }

    private static String readBody(Response response)
    {
        try {
            return new String(toByteArray(response.getInputStream()), US_ASCII);
        }
        catch (IOException e) {
            return "";
        }
    }

    public static class ProxyResponse
    {
        private final ListMultimap<HeaderName, String> headers;
        private final byte[] body;

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Check the wrapped IOException cause for 'reset'/'timeout' specifics.
  2. Increase HTTP client read timeouts and any intermediary idle timeouts.
  3. Retry the request; for large results reduce page size or use spooling.
  4. Check backend server logs for errors at the time of the failure.
Defensive patterns

Strategy: retry

Validate before calling

// estimate body transfer time and ensure timeouts exceed it
const head = await fetch(backendUri + path, { method: "HEAD" });
const bytes = Number(head.headers.get("content-length") || 0);
if (bytes / minBytesPerSecond > readTimeoutSeconds) console.warn("read timeout too small for body size", bytes);

Try / catch

try {
  return await proxyCall(req);
} catch (e) {
  if (String(e.message).includes("Failed reading response")) {
    return retryWithBackoff(req, 3); // transient stream failure
  }
  throw e;
}

Prevention

When it happens

Trigger: Connection reset or timeout while streaming the response body; server closed the connection prematurely; client-side stream/disk issues while buffering the body.

Common situations: Large result sets hitting read timeouts; backend OOM-killed mid-response; flaky network or LB idle-timeout smaller than body transfer time.

Related errors


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