apache/seatunnel · critical · ClickhouseConnectorException
Failed to connect to host: " + host + " by user: " + user +
Error message
Failed to connect to host: " + host + " by user: " + user + " on port 22
What it means
ScpFileTransfer.init() catches IOException or GeneralSecurityException during connection/auth setup and rethrows it as SSH_OPERATION_FAILED with a 'Failed to connect to host ... on port 22' message. This is the generic SSH connect failure — the TCP/SSH handshake or crypto setup failed before authentication could be evaluated.
Source
Thrown at seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/file/ScpFileTransfer.java:87
clientSession = sshClient.connect(user, host, SCP_PORT).verify().getSession();
if (password != null) {
clientSession.addPasswordIdentity(password);
}
if (keyPath != null) {
FileKeyPairProvider fileKeyPairProvider =
new FileKeyPairProvider(Paths.get(keyPath));
KeyPair fileKeyPair =
fileKeyPairProvider.loadKey(clientSession, KeyPairProvider.SSH_RSA);
clientSession.addPublicKeyIdentity(fileKeyPair);
}
if (!clientSession.auth().verify().isSuccess()) {
throw new ClickhouseConnectorException(
ClickhouseConnectorErrorCode.SSH_OPERATION_FAILED,
"ssh host " + host + "authentication failed");
}
scpClient = ScpClientCreator.instance().createScpClient(clientSession);
} catch (IOException | GeneralSecurityException e) {
throw new ClickhouseConnectorException(
ClickhouseConnectorErrorCode.SSH_OPERATION_FAILED,
"Failed to connect to host: " + host + " by user: " + user + " on port 22",
e);
}
}
@Override
public void transferAndChown(String sourcePath, String targetPath) {
try {
scpClient.upload(
sourcePath,
targetPath,
ScpClient.Option.Recursive,
ScpClient.Option.TargetIsDirectory,
ScpClient.Option.PreserveAttributes);
} catch (IOException e) {
throw CommonError.fileOperationFailed(
"ClickhouseFile", "transfer", sourcePath + " -> " + targetPath, e);View on GitHub (pinned to cf67b549a7)
Solutions
- Test connectivity from the SeaTunnel worker: nc -vz <host> 22 or ssh user@host
- Verify the host address and that sshd is running on the remote machine
- Open port 22 in firewalls/security groups between worker and host
- Confirm the key file at keyPath exists and is readable by the process user (check permissions and path)
- Note the message hardcodes 'port 22'; if a custom port is used in config, ignore that part and check the actual configured port
Example fix
// before: unreachable host host = "10.0.0.99" // after: correct, reachable host (and open port 22) host = "10.0.0.10"
Defensive patterns
Strategy: validation
Validate before calling
# pre-flight connectivity check from the SeaTunnel worker host nc -vz -w 5 "$HOST" 22 && echo ssh-port-open [ -r "$KEY_PATH" ] && echo key-readable
Try / catch
try {
transfer.init();
} catch (ClickhouseConnectorException e) {
if (String.valueOf(e.getMessage()).startsWith("Failed to connect to host")) {
// inspect e.getCause(): UnknownHost vs ConnectException vs timeout vs security
log.error("SSH connect failed to {} : {}", host, e.getCause());
}
throw e;
} Prevention
- Pre-flight nc/ssh connectivity checks in deployment scripts
- Open port 22 (or configured port) in firewalls/security groups
- Verify DNS resolution of the host from worker nodes
- Confirm key file path and read permissions
When it happens
Trigger: new connect to host:22 throws (connection refused/timeout/unreachable/DNS failure) or key loading throws GeneralSecurityException (unreadable/corrupt key file at keyPath).
Common situations: Firewall or security group blocking port 22, wrong host/port in config, remote sshd not running, DNS misresolution, or the SSH key file missing/unreadable by the SeaTunnel worker process.
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
- Failed to close ssh session
- Failed to close ssh client
- Failed to connect to host: " + host + " by user: " + user +
- Failed to close ssh session
- Failed to close ssh client
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/9d5042d27638c265.
Report an issue: GitHub.