{"record":{"id":"d429698b19b186fa","repo":"apache/hadoop","slug":"unable-to-create-file-file-aborting","errorCode":null,"errorMessage":"Unable to create file: {file}, Aborting","messagePattern":"Unable to create 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":356,"sourceCode":"      throw new IOException(\"create(): Mkdirs failed to create: \" + parent);\n    }\n    client.allocate(bufferSize);\n    // Change to parent directory on the server. Only then can we write to the\n    // file on the server by opening up an OutputStream. As a side effect the\n    // working directory on the server is changed to the parent directory of the\n    // file. The FTP client connection is closed when close() is called on the\n    // FSDataOutputStream.\n    client.changeWorkingDirectory(parent.toUri().getPath());\n    OutputStream outputStream = client.storeFileStream(file.getName());\n\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      if (outputStream != null) {\n        IOUtils.closeStream(outputStream);\n      }\n      disconnect(client);\n      throw new IOException(\"Unable to create file: \" + file + \", Aborting\");\n    }\n\n    FSDataOutputStream fos = new FSDataOutputStream(outputStream, statistics) {\n      @Override\n      public void close() throws IOException {\n        super.close();\n        if (!client.isConnected()) {\n          throw new FTPException(\"Client not connected\");\n        }\n        boolean cmdCompleted = client.completePendingCommand();\n        disconnect(client);\n        if (!cmdCompleted) {\n          throw new FTPException(\"Could not complete transfer, Reply Code - \"\n              + client.getReplyCode());\n        }\n      }\n    };\n    return fos;","sourceCodeStart":338,"sourceCodeEnd":374,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ftp/FTPFileSystem.java#L338-L374","documentation":"In create(), after changing to the parent directory, storeFileStream (STOR) did not get a positive preliminary reply, so the server refused to start the upload. Any stream handle is closed, the client disconnected, and create() fails with this IOException.","triggerScenarios":"FTP user lacks write permission in the target directory; the target name already exists as a directory; server disk full or quota exceeded; data connection mode blocked by firewall so the server rejects STOR upfront.","commonSituations":"Upload directories with restrictive ownership; disk-full FTP servers; active-mode data channels blocked by NAT/firewall (server refuses the transfer before it starts).","solutions":["Verify the same user can upload manually: curl -T localfile ftp://user@host/dir/","Check the target directory is writable: FsAction.WRITE in getFileStatus(dir).getPermission()","Rule out disk-full or quota on the server","Switch to passive mode: conf.set(\"fs.ftp.data.connection.mode\", \"PASSIVE_LOCAL_DATA_CONNECTION_MODE\") if active mode is blocked"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"Path parent = file.getParent();\nif (fs.exists(parent)) {\n  FsPermission perm = fs.getFileStatus(parent).getPermission();\n  if (!perm.getUserAction().and(FsAction.WRITE).equals(FsAction.WRITE)) {\n    throw new IOException(\"No FTP write permission in \" + parent);\n  }\n}\nFSDataOutputStream out = fs.create(file, true);","typeGuard":null,"tryCatchPattern":"try {\n  out = fs.create(file, true);\n} catch (IOException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Unable to create file\")) {\n    // server refused STOR: surface context (permission/quota/firewall) instead of the raw text\n    throw new IOException(\"FTP server refused STOR for \" + file, e);\n  }\n  throw e;\n}","preventionTips":["Confirm the FTP account can upload one file manually before running jobs","Ensure the target name is not already a directory on the server","Check server disk/quota when create fails only for some paths or large files"],"tags":["ftp","stor","permission-denied","transfer"],"backgroundTag":"file-write-permission-denied","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}