apache/seatunnel · error · 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
RsyncFileTransfer.init wraps IOException/GeneralSecurityException from establishing or authenticating the SSH session in an SSH_OPERATION_FAILED exception whose message is "Failed to connect to host: <host> by user: <user> on port 22", with the original exception as cause.
Source
Thrown at seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/file/RsyncFileTransfer.java:86
sshClient.start();
clientSession = sshClient.connect(user, host, SSH_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");
}
} 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 {
String sshParameter =
password != null
? String.format(
"'sshpass -p %s ssh -o StrictHostKeyChecking=no -p %s'",
password, SSH_PORT)
: keyPath != null
? String.format(
"'ssh -i %s -o StrictHostKeyChecking=no -p %s'",
keyPath, SSH_PORT)View on GitHub (pinned to cf67b549a7)
Solutions
- Check the chained cause for the exact network/IO error
- Verify connectivity: `ssh <user>@<host>` or `nc -vz <host> 22` from the SeaTunnel worker machine
- Confirm sshd is running on the ClickHouse node and the firewall allows port 22
- Fix the hostname/IP and user in the sink configuration
Defensive patterns
Strategy: retry
Try / catch
try {
transfer.init();
} catch (ClickhouseConnectorException e) {
if (e.getMessage() != null && e.getMessage().contains("Failed to connect to host")) {
// check network/sshd/firewall before retrying with backoff
}
} Prevention
- Verify port 22 reachability from worker to each ClickHouse node before job submission
- Run sshd on all shard nodes and allow it in firewall rules
- Use stable hostnames/IPs with correct DNS
When it happens
Trigger: init when the SSH connection to port 22 fails — host unreachable, wrong host/port, firewall blocking, SSH daemon down, DNS failure, or a GeneralSecurityException during crypto/key handling.
Common situations: ClickHouse node firewall blocks port 22 from the worker; sshd not running on the target; hostname typo or stale DNS; network partition between SeaTunnel worker and ClickHouse node.
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/8921454d20ea50d1.
Report an issue: GitHub.