{"record":{"id":"bfab2307f57f4cb3","repo":"apache/hadoop","slug":"unable-to-open-file-file-aborting","errorCode":null,"errorMessage":"Unable to open file: {file}, Aborting","messagePattern":"Unable to open file: (.+?), Aborting","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ftp/FTPFileSystem.java","lineNumber":303,"sourceCode":"    }\n    client.allocate(bufferSize);\n    Path parent = absolute.getParent();\n    // Change to parent directory on the\n    // server. Only then can we read the\n    // file\n    // on the server by opening up an InputStream. As a side effect the working\n    // directory on the server is changed to the parent directory of the file.\n    // The FTP client connection is closed when close() is called on the\n    // FSDataInputStream.\n    client.changeWorkingDirectory(parent.toUri().getPath());\n    InputStream is = client.retrieveFileStream(file.getName());\n    FSDataInputStream fis = new FSDataInputStream(new FTPInputStream(is,\n        client, statistics));\n    if (!FTPReply.isPositivePreliminary(client.getReplyCode())) {\n      // The ftpClient is an inconsistent state. Must close the stream\n      // which in turn will logout and disconnect from FTP server\n      fis.close();\n      throw new IOException(\"Unable to open file: \" + file + \", Aborting\");\n    }\n    return fis;\n  }\n\n  /**\n   * A stream obtained via this call must be closed before using other APIs of\n   * this class or else the invocation will block.\n   */\n  @Override\n  public FSDataOutputStream create(Path file, FsPermission permission,\n      boolean overwrite, int bufferSize, short replication, long blockSize,\n      Progressable progress) throws IOException {\n    final FTPClient client = connect();\n    Path workDir = new Path(client.printWorkingDirectory());\n    Path absolute = makeAbsolute(workDir, file);\n    FileStatus status;\n    try {\n      status = getFileStatus(client, file);","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ftp/FTPFileSystem.java#L285-L321","documentation":"In open(), after changing to the parent directory and issuing RETR via retrieveFileStream, the server's reply was not 1xx (positive preliminary), so no data transfer was started. The half-open stream is closed (which also logs out and disconnects) and the IOException aborts the open.","triggerScenarios":"The FTP user lacks read permission on the file; the file was removed/renamed between getFileStatus and RETR; server policy (quota, IP allowlist on data connections) rejects the download; active-mode data channel blocked so the server refuses to start the transfer.","commonSituations":"Firewalls blocking FTP data connections (the default fs.ftp.data.connection.mode is ACTIVE_LOCAL_DATA_CONNECTION_MODE — try PASSIVE_LOCAL_DATA_CONNECTION_MODE); files with restrictive ownership on the server; antivirus/policy engines rejecting specific file types.","solutions":["Reproduce manually with the same credentials: curl ftp://user@host/dir/file or lftp","Check read permission via fs.getFileStatus(path).getPermission() (FTP READ_PERMISSION is mapped to FsAction.READ)","If active mode is blocked, set conf.set(\"fs.ftp.data.connection.mode\", \"PASSIVE_LOCAL_DATA_CONNECTION_MODE\")","Check the FTP server log for the RETR reply code to get the exact refusal reason"],"exampleFix":"// before\nConfiguration conf = new Configuration();\nconf.set(\"fs.ftp.host\", \"ftp.example.com\");\nFSDataInputStream in = fs.open(path); // RETR refused\n\n// after\nConfiguration conf = new Configuration();\nconf.set(\"fs.ftp.host\", \"ftp.example.com\");\nconf.set(\"fs.ftp.data.connection.mode\", \"PASSIVE_LOCAL_DATA_CONNECTION_MODE\");\nFSDataInputStream in = fs.open(path);","handlingStrategy":"validation","validationCode":"FileStatus st = fs.getFileStatus(path);\nif (!st.getPermission().getUserAction().and(FsAction.READ).equals(FsAction.READ)) {\n  throw new IOException(\"No FTP read permission for \" + path);\n}\nFSDataInputStream in = fs.open(path);","typeGuard":null,"tryCatchPattern":"try {\n  in = fs.open(path);\n} catch (IOException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Unable to open file\")) {\n    // server refused RETR: check permission / data-connection mode, then fail with context\n    throw new IOException(\"FTP server refused RETR for \" + path, e);\n  }\n  throw e;\n}","preventionTips":["Verify one file downloads manually with the same credentials before wiring a pipeline","Behind NAT/firewall, set fs.ftp.data.connection.mode=PASSIVE_LOCAL_DATA_CONNECTION_MODE up front","Check for files renamed/removed between status check and open in concurrent setups"],"tags":["ftp","retr","permission-denied","transfer"],"backgroundTag":"file-read-permission-denied","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}