{"record":{"id":"464e598351ea7efa","repo":"prestodb/presto","slug":"druid-broker-result-error-464e59","errorCode":"DRUID_BROKER_RESULT_ERROR","errorMessage":"Request to worker failed","messagePattern":"Request to worker failed","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"critical","filePath":"presto-druid/src/main/java/com/facebook/presto/druid/DruidClient.java","lineNumber":189,"sourceCode":"                .setBodyGenerator(createStaticBodyGenerator(createRequestBody(query, OBJECT_LINES, false)))\n                .build();\n    }\n\n    private Request prepareDataIngestion(DruidIngestTask ingestTask)\n    {\n        HttpUriBuilder uriBuilder = uriBuilderFrom(druidCoordinator).replacePath(INDEXER_TASK_ENDPOINT);\n        return setContentTypeHeaders(preparePost())\n                .setUri(uriBuilder.build())\n                .setBodyGenerator(createStaticBodyGenerator(ingestTask.toJson().getBytes()))\n                .build();\n    }\n    private static class StreamingJsonResponseHandler\n            implements ResponseHandler<InputStream, RuntimeException>\n    {\n        @Override\n        public InputStream handleException(Request request, Exception exception)\n        {\n            throw new PrestoException(DRUID_BROKER_RESULT_ERROR, \"Request to worker failed\", exception);\n        }\n\n        @Override\n        public InputStream handle(Request request, com.facebook.airlift.http.client.Response response)\n        {\n            try {\n                if (response.getStatusCode() != HTTP_OK) {\n                    String result = new BufferedReader(new InputStreamReader(response.getInputStream())).lines().collect(Collectors.joining(\"\\n\"));\n                    throw new PrestoException(DRUID_BROKER_RESULT_ERROR, result);\n                }\n                if (APPLICATION_JSON.equals(response.getHeader(CONTENT_TYPE))) {\n                    return response.getInputStream();\n                }\n                throw new PrestoException(DRUID_BROKER_RESULT_ERROR, \"Response received was not of type \" + APPLICATION_JSON);\n            }\n            catch (IOException e) {\n                throw new PrestoException(DRUID_BROKER_RESULT_ERROR, \"Unable to read response from worker\", e);\n            }","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-druid/src/main/java/com/facebook/presto/druid/DruidClient.java#L171-L207","documentation":"Thrown from StreamingJsonResponseHandler.handleException in DruidClient when the Airlift HTTP client fails at the transport level while sending a request to a Druid worker (broker or coordinator indexer). Any Exception raised by the HTTP client (connect failure, TLS error, timeout, connection refused) is wrapped in a DRUID_BROKER_RESULT_ERROR PrestoException with message \"Request to worker failed\". The original exception is preserved as the cause.","triggerScenarios":"DruidClient.getData or ingestData invokes httpClient.execute and the airlift ResponseHandler's handleException callback fires — i.e. the HTTP request to the Druid broker/coordinator never completed successfully (connect refused, DNS failure, TLS handshake failure, request timeout).","commonSituations":"Wrong druid-broker-url / druid-coordinator-url in Druid connector config; Druid process down or restarting; firewall/security-group blocking the port; DNS misconfiguration; certificate expiry on HTTPS endpoints.","solutions":["Check the exception's cause for the exact transport error (Connection refused, UnknownHost, SSLHandshakeException, timeout).","Verify druid-broker-url and druid-coordinator-url properties point to reachable host:port (curl the broker URL from the Presto coordinator/worker host).","Confirm the Druid broker/coordinator services are running and listening (process status, listening ports).","Check network paths: firewalls, security groups, DNS resolution, and TLS certificate validity if using HTTPS.","Increase HTTP connect timeout settings if failures occur under load or slow network conditions."],"exampleFix":"// before (etc/druid/druid.properties): wrong host\nconnector.name=druid\ndruid-broker-url=http://druid-broker-internal:8082\n\n// after: correct, reachable broker endpoint (verify with curl first)\ndruid-broker-url=http://druid-broker.prod.internal:8082\ndruid-coordinator-url=http://druid-coordinator.prod.internal:8081","handlingStrategy":"validation","validationCode":"// Preflight connectivity checks from the Presto host before running queries:\ncurl -sf --max-time 5 http://druid-broker:8082/status || echo \"broker unreachable\"\ncurl -sf --max-time 5 http://druid-coordinator:8081/status || echo \"coordinator unreachable\"\n// Also verify DNS: getent hosts druid-broker.prod.internal","typeGuard":null,"tryCatchPattern":"try {\n    InputStream in = druidClient.getData(dql);\n} catch (PrestoException e) {\n    if (e.getCause() != null) {\n        // Connection refused / UnknownHost / SSLHandshakeException live in the cause\n        log.error(\"Druid transport failure: \" + e.getCause().getClass().getSimpleName(), e.getCause());\n    }\n    throw e;\n}","preventionTips":["Validate druid-broker-url and druid-coordinator-url with curl from the actual Presto host","Add health checks/monitoring on Druid broker and coordinator endpoints","Keep TLS certificates current when using HTTPS Druid endpoints","Document firewall/security-group rules for Druid ports (8081/8082)"],"tags":["druid","presto","http-client","connection-refused","network"],"backgroundTag":"connection-refused","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"}