apache/druid · error · IllegalArgumentException
Failed to construct server URL.
Error message
Failed to construct server URL.
What it means
When creating a DruidServerHolder, the server's host string is converted into a URL for the queryable-server syncer. A MalformedURLException from that conversion is wrapped in IAE with this message, meaning the configured host string is not a valid URL/authority format.
Source
Thrown at server/src/main/java/org/apache/druid/client/HttpServerInventoryView.java:562
{
this.druidServer = druidServer;
try {
HostAndPort hostAndPort = HostAndPort.fromString(druidServer.getHost());
this.syncer = new ChangeRequestHttpSyncer<>(
smileMapper,
httpClient,
inventorySyncExecutor,
new URL(druidServer.getScheme(), hostAndPort.getHost(), hostAndPort.getPort(), "/"),
"/druid-internal/v1/segments",
SEGMENT_LIST_RESP_TYPE_REF,
config.getServerTimeout(),
config.getServerUnstabilityTimeout(),
createSyncListener()
);
}
catch (MalformedURLException ex) {
throw new IAE(ex, "Failed to construct server URL.");
}
}
void start()
{
syncer.start();
}
void stop()
{
syncer.stop();
stopped.set(true);
}
boolean isStopped()
{
return stopped.get();
}View on GitHub (pinned to 9b90983fd2)
Solutions
- Fix the offending host string to be scheme://hostname:port (valid URL authority)
- Validate host configuration at startup before it reaches the inventory view
- Check the external discovery source for malformed entries
- Log/inspect the wrapped MalformedURLException cause for the exact parse failure
Example fix
// before config.getHost() == "http:/broker1:8080" // MalformedURLException // after config.getHost() == "http://broker1:8080"
Defensive patterns
Strategy: validation
Validate before calling
private static void validateHost(String host) {
try { new java.net.URL(host); } catch (MalformedURLException e) { throw new IllegalArgumentException("bad host: " + host, e); }
} Prevention
- Validate host strings as URLs at config load time
- Use scheme://hostname:port format consistently
- Check discovery service output format
When it happens
Trigger: druid.client.httpServerInventory entries or discovery payloads containing hosts with invalid characters, missing scheme/hostname, or malformed host:port values.
Common situations: Typo'd host config (e.g. 'http:/host:8080' single slash), whitespace or control characters in host, port values with invalid characters, discovery service returning malformed host strings.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- %s: Malformed url for DruidNode [%s] and baseUrl [%s]
- Bad URL: %s
- The gRPC query server requires either a Basic or Anonymous a
- Metric [%s] not whitelisted.
- Can't load TrustStore. Truststore path or password is not se
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/3caacfdefa63e0c3.
Report an issue: GitHub.