apache/hadoop · error · FTPException

Could not complete transfer, Reply Code - {replyCode}

Error message

Could not complete transfer, Reply Code - {replyCode}

What it means

On stream close, completePendingCommand() must collect the final FTP reply that ends the data transfer. A false return means the server aborted or never completed the STOR — the exception carries the reply code (e.g. 426 transfer aborted, 451 local error, 552 quota exceeded) and the file on the server is likely partial or absent.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ftp/FTPFileSystem.java:369

      // which in turn will logout and disconnect from FTP server
      if (outputStream != null) {
        IOUtils.closeStream(outputStream);
      }
      disconnect(client);
      throw new IOException("Unable to create file: " + file + ", Aborting");
    }

    FSDataOutputStream fos = new FSDataOutputStream(outputStream, statistics) {
      @Override
      public void close() throws IOException {
        super.close();
        if (!client.isConnected()) {
          throw new FTPException("Client not connected");
        }
        boolean cmdCompleted = client.completePendingCommand();
        disconnect(client);
        if (!cmdCompleted) {
          throw new FTPException("Could not complete transfer, Reply Code - "
              + client.getReplyCode());
        }
      }
    };
    return fos;
  }

  /** This optional operation is not yet supported. */
  @Override
  public FSDataOutputStream append(Path f, int bufferSize,
      Progressable progress) throws IOException {
    throw new UnsupportedOperationException("Append is not supported "
        + "by FTPFileSystem");
  }
  
  /**
   * Convenience method, so that we don't open a new connection when using this
   * method from within another method. Otherwise every API invocation incurs

View on GitHub (pinned to 2add963021)

Solutions

  1. Read the reply code from the exception message and match it against the FTP server log
  2. Check server disk space and the user's quota, then retry the write
  3. Verify the uploaded file (size/hash) on the server; delete partial files before retrying
  4. Reduce concurrent uploads if the server is refusing under load
Defensive patterns

Strategy: retry

Try / catch

try (FSDataOutputStream out = fs.create(path, true)) {
  out.write(data);
} catch (FTPException e) {
  // reply code is in the message; transfer did not complete
  LOG.warn("FTP transfer incomplete: {}", e.getMessage());
  fs.delete(path, false); // drop the partial file
  retryWrite(fs, path, data); // server-side quota/disk issues must be fixed first
}

Prevention

When it happens

Trigger: Server runs out of disk/quota mid-upload; data connection broken mid-transfer; server-side antivirus or policy aborts the file; control connection returns 4xx/5xx at completion time.

Common situations: Disk-full FTP servers failing only for large uploads; quotas hit mid-file; flaky networks where the data channel dies but the control channel survives long enough to report.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/3a717c42ec64b93c. Report an issue: GitHub.