{"record":{"id":"47d8e02e1ce9d738","repo":"prestodb/presto","slug":"ttransportexception","errorCode":null,"errorMessage":"TTransportException","messagePattern":"TTransportException","errorType":"exception","errorClass":"TTransportException","httpStatus":null,"severity":"critical","filePath":"presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/thrift/Transport.java","lineNumber":88,"sourceCode":"            socket.setSoTimeout(timeoutMillis);\n\n            if (sslContext.isPresent()) {\n                // SSL will connect to the SOCKS address when present\n                HostAndPort sslConnectAddress = socksProxy.orElse(address);\n\n                socket = sslContext.get().getSocketFactory().createSocket(socket, sslConnectAddress.getHost(), sslConnectAddress.getPort(), true);\n            }\n            return new TSocket(socket);\n        }\n        catch (Throwable t) {\n            // something went wrong, close the socket and rethrow\n            try {\n                socket.close();\n            }\n            catch (IOException e) {\n                t.addSuppressed(e);\n            }\n            throw new TTransportException(t);\n        }\n    }\n\n    private static TTransportException rewriteException(TTransportException e, HostAndPort address)\n    {\n        return new TTransportException(e.getType(), String.format(\"%s: %s\", address, e.getMessage()), e);\n    }\n\n    @VisibleForTesting\n    static class TTransportWrapper\n            extends TTransport\n    {\n        private final TTransport transport;\n        private final HostAndPort address;\n\n        TTransportWrapper(TTransport transport, HostAndPort address)\n        {\n            this.transport = transport;","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/thrift/Transport.java#L70-L106","documentation":"Transport.createRaw opens a Thrift socket transport to the Hive Metastore host. On connection failure the underlying IOException is caught and rethrown as a TTransportException, then rewriteException prefixes the message with the target host:port. This is the standard 'cannot reach the Metastore' error: DNS failure, refused connection, timeout, or TLS handshake problems all surface here as TTransportException.","triggerScenarios":"Calling createRaw/rawTransport when the Metastore URI host is unreachable: connection refused (service down), UnknownHost (bad DNS/hostname in hive.metastore.uri), connect timeout (firewall/security group), or TLS failure on thrifts:// URIs.","commonSituations":"Metastore service stopped or restarting; wrong host/port in catalog properties (hive.metastore.uri); Kubernetes/network policy blocking the port; DNS misconfiguration; Kerberos/TLS handshake issues on port 9083/10000.","solutions":["Verify the Metastore service is running and listening on the configured host:port (nc -vz host 9083)","Check hive.metastore.uri in the catalog properties for typos (thrift://host:9083) and DNS resolution of the host","Check network/firewall/security-group rules between Presto coordinator/worker and the Metastore","Inspect Metastore service logs; restart the Metastore if it is hung, and review thrift transport timeouts/TLS settings"],"exampleFix":"// before\nhive.metastore.uri=thrift://metastore-internal:9084\n// after (correct host/port, service reachable)\nhive.metastore.uri=thrift://metastore.internal.example.com:9083","handlingStrategy":"retry","validationCode":"// pre-flight reachability check before creating the transport\nHostAndPort addr = HostAndPort.fromString(metastoreUri.getHost());\ntry (Socket s = new Socket()) {\n    s.connect(new InetSocketAddress(addr.getHost(), addr.getPort()), 3000); // fails fast if unreachable\n} catch (IOException e) {\n    throw new PrestoException(HIVE_METASTORE_ERROR, \"Metastore unreachable at \" + addr, e);\n}","typeGuard":"boolean isMetastoreUriReachable(URI uri) {\n    try (Socket s = new Socket()) {\n        s.connect(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 9083 : uri.getPort()), 3000);\n        return true;\n    } catch (IOException e) { return false; }\n}","tryCatchPattern":"// retry with backoff on TTransportException, then surface address\nint attempts = 3;\nfor (int i = 1; i <= attempts; i++) {\n    try {\n        return Transport.createRaw(...);\n    } catch (TTransportException e) {\n        if (i == attempts) throw new PrestoException(HIVE_METASTORE_ERROR,\n            \"Cannot connect to metastore (see cause for host)\", e);\n        Thread.sleep(1000L * i);\n    }\n}","preventionTips":["Monitor the Metastore service and port (9083) with health checks","Pin a resolvable DNS name in hive.metastore.uri; avoid short-lived pod IPs","Open firewall/security-group paths from Presto nodes to the Metastore","Configure thrift transport timeouts and retries in catalog properties"],"tags":["network","thrift","hive-metastore","connection"],"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"}