prestodb/presto · critical · TException
Failed connecting to Hive metastore: ${addresses}
Error message
Failed connecting to Hive metastore: ${addresses} What it means
StaticHiveCluster.createMetastoreClient loops over every configured metastore URI and attempts a Thrift connection; if all attempts fail with a TException, it throws this aggregate TException with the list of addresses and the last underlying exception as its cause. It means Presto could not open a working Thrift session to any Hive metastore host in the static cluster.
Source
Thrown at presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/thrift/StaticHiveCluster.java:89
if (metastoreLoadBalancingEnabled) {
Collections.shuffle(metastores);
}
TException lastException = null;
for (HostAndPort metastore : metastores) {
try {
HiveMetastoreClient client = clientFactory.create(metastore, token);
if (!isNullOrEmpty(metastoreUsername)) {
client.setUGI(metastoreUsername);
}
return client;
}
catch (TException e) {
lastException = e;
}
}
throw new TException("Failed connecting to Hive metastore: " + addresses, lastException);
}
private static URI checkMetastoreUri(URI uri)
{
requireNonNull(uri, "metastoreUri is null");
String scheme = uri.getScheme();
checkArgument(!isNullOrEmpty(scheme), "metastoreUri scheme is missing: %s", uri);
checkArgument(scheme.equals("thrift"), "metastoreUri scheme must be thrift: %s", uri);
checkArgument(uri.getHost() != null, "metastoreUri host is missing: %s", uri);
checkArgument(uri.getPort() != -1, "metastoreUri port is missing: %s", uri);
return uri;
}
}
View on GitHub (pinned to 55bb57d202)
Solutions
- Verify the metastore is up and listening: run `nc -vz <host> 9083` from the Presto coordinator and start hive-metastore service if down
- Check hive.metastore.thrift.uris values for typos in host/port/scheme; confirm the port matches hive.metastore.uris on the metastore side
- Inspect the `cause` (lastException) of this exception in the coordinator log — it holds the real per-host failure (refused, timeout, SSL, SASL)
- Open firewall/security groups for the metastore port and confirm DNS resolves the configured hostnames
- If metastore is healthy but slow, raise hive.metastore.thrift.client.connect-timeout / read-timeout and metastore refresh settings
Example fix
// before hive.metastore=thrift hive.metastore.thrift.uris=thrift://meta-internal:9083 // after hive.metastore=thrift hive.metastore.thrift.uris=thrift://metastore-host.example.com:9083 # verified with: nc -vz metastore-host.example.com 9083
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-flight: verify at least one metastore URI is reachable before initializing the catalog
List<String> uris = Arrays.asList("thrift://metastore-host.example.com:9083");
for (String uri : uris) {
try {
URI u = new URI(uri);
try (Socket s = new Socket()) {
s.connect(new InetSocketAddress(u.getHost(), u.getPort()), 3000); // fails fast if refused
}
} catch (Exception e) {
throw new IllegalStateException("Metastore unreachable: " + uri, e);
}
} Type guard
public static boolean isConnectionFailure(Throwable t) {
Throwable root = t;
while (root.getCause() != null) root = root.getCause();
return root instanceof ConnectException || root instanceof UnknownHostException
|| root instanceof SocketTimeoutException || root instanceof TTransportException;
} Try / catch
try {
HiveMetastoreClient client = staticHiveCluster.createMetastoreClient(metastoreContext);
} catch (TException e) {
if (isConnectionFailure(e)) {
log.error("No metastore host reachable; cause={}", rootCause(e).getMessage(), e);
throw new RetriableException("Metastore cluster unreachable: " + e.getMessage(), e);
}
throw e;
} Prevention
- Configure multiple metastore URIs for redundancy and keep them in sync with service discovery
- Run nc -vz host 9083 health checks in monitoring for every configured metastore host
- Match connect/read timeouts to metastore latency SLOs
- Verify DNS and firewall rules from Presto nodes during environment provisioning
When it happens
Trigger: Any Presto query or catalog operation requiring metastore access when none of the URIs in hive.metastore (or the hive.metastore.thrift.uris list) accept a connection: connection refused, TLS handshake failure, auth failure, or timeout on each host.
Common situations: Metastore service down or never started; wrong hive.metastore.thrift.uris port (default 9083); firewall/security-group blocking; kerberos or SSL misconfiguration on the client; metastore host DNS not resolving inside containers; metastore overloaded and dropping connections.
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
- TTransportException
- UNEXPECTED_ACCUMULO_ERROR
- Unable to query ranger service
- HIVE_METASTORE_ERROR
- GrantRevokeResponse missing success field
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/a15efafa71020620.
Report an issue: GitHub.