pentaho/pentaho-kettle · error · KettleJobException

Max connection attempts reached

Error message

Max connection attempts reached

What it means

SFTPClient.login() retries tryCreateNewConnection() up to a configurable number of attempts, decrementing maxConnectionAttempts each round. If every attempt fails and the counter reaches zero, it throws this KettleJobException indicating the server could not be reached within the retry budget.

Solutions

  1. Verify host, port, and network reachability (ping/nc to the SFTP port).
  2. Increase the max connection attempts and/or delay settings to tolerate slow servers.
  3. Check SFTP server logs and firewall rules for dropped connections.
  4. Inspect tryCreateNewConnection's swallowed failure cause (enable logging) to see why connections fail.

Example fix

// before (job entry config)
maxConnectionAttempts = 1; delay = 0;
// after
maxConnectionAttempts = 5; delay = 1000;
Defensive patterns

Strategy: retry

Validate before calling

// before login
boolean reachable;
try (Socket s = new Socket()) { s.connect(new InetSocketAddress(host, port), 3000); reachable = true; }
catch (IOException e) { reachable = false; }

Try / catch

try {
  client.login();
} catch (KettleJobException e) {
  if ("Max connection attempts reached".equals(e.getMessage())) alertOps("SFTP unreachable: " + host);
}

Prevention

When it happens

Trigger: Calling login() (directly or via testDir/testDirNoFiles/SFTP job entry execute) where tryCreateNewConnection() returns false on every retry until maxConnectionAttempts <= 0.

Common situations: SFTP server down or unreachable (network/firewall); wrong host/port; too many connection attempts configured too low for a slow server; server rejecting repeated handshakes.

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


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/d041efba874e9cfd. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/job/entries/sftp/SFTPClient.java:190

  private static byte[] getFileContent( Bowl bowl, String vfsFileName ) throws KettleFileException, IOException {
    return FileObjectUtils.getContentAsByteArray( KettleVFS.getInstance( bowl ).getFileObject( vfsFileName ) );
  }

  public void login( String password ) throws KettleJobException {
    this.password = password;
    // up to a total of 6 seconds delay max per connection attempt
    int maxConnectionAttempts = 62;
    int delayBetweenEachAttempts = 100; // milliseconds

    while ( true ) {
      try {
        if ( tryCreateNewConnection( ) ) {
          break;
        }

        if ( --maxConnectionAttempts <= 0 ) {
          throw new KettleJobException( "Max connection attempts reached" );
        }
        Thread.sleep( delayBetweenEachAttempts );
        // incrementing delay by 100 milliseconds
        delayBetweenEachAttempts += 100;

      } catch ( InterruptedException ex ) {
        Thread.currentThread().interrupt();
        throw new KettleJobException( "Interrupted during a retry ", ex );
      } catch ( Exception e ) {
        throw new KettleJobException( "An unexpected error has occurred ", e );
      }
    }
  }

  private boolean tryCreateNewConnection(  ) {
    try {
      session.setPassword( this.getPassword() );
      java.util.Properties config = new java.util.Properties();

View on GitHub (pinned to f3058517a1)