{"record":{"id":"847601b91404eb01","repo":"apache/hadoop","slug":"block-could-not-be-located-path-offset","errorCode":null,"errorMessage":"Block could not be located. Path={}, offset={}","messagePattern":"Block could not be located\\. Path=(.+?), offset=(.+?)","errorType":"http","errorClass":"IOException","httpStatus":403,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java","lineNumber":340,"sourceCode":"        throw new FileNotFoundException(\"File \" + path + \" not found.\");\n      }\n\n      final long len = status.getLen();\n      if (op == GetOpParam.Op.OPEN) {\n        if (openOffset < 0L || (openOffset >= len && len > 0)) {\n          throw new IOException(\"Offset=\" + openOffset\n              + \" out of the range [0, \" + len + \"); \" + op + \", path=\" + path);\n        }\n      }\n\n      if (len > 0) {\n        final long offset = op == GetOpParam.Op.OPEN? openOffset: len - 1;\n        final LocatedBlocks locations = np.getBlockLocations(path, offset, 1);\n        final int count = locations.locatedBlockCount();\n        if (count > 0) {\n          return bestNode(locations.get(0).getLocations(), excludes);\n        } else {\n          throw new IOException(\"Block could not be located. Path=\" + path + \", offset=\" + offset);\n        }\n      }\n    }\n\n    // All other operations don't affect a specific node so let the BlockManager pick a target\n    DatanodeDescriptor clientNode = bm.getDatanodeManager(\n    ).getDatanodeByHost(remoteAddr);\n\n    DatanodeStorageInfo[] storages = bm.chooseTarget4WebHDFS(\n      path, clientNode, excludes, blocksize);\n    if (storages.length > 0) {\n      return storages[0].getDatanodeDescriptor();\n    }\n\n    return (DatanodeDescriptor)bm.getDatanodeManager().getNetworkTopology(\n        ).chooseRandom(NodeBase.ROOT, excludes);\n  }\n","sourceCodeStart":322,"sourceCodeEnd":358,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java#L322-L358","documentation":"Error \"Block could not be located. Path={}, offset={}\" thrown in apache/hadoop.","triggerScenarios":"No located block exists for the requested path/offset during a WebHDFS read.","commonSituations":"Reading a zero-length file region, a file still under construction, or blocks not yet reported.","solutions":["Verify the file has data at that offset and that blocks are available; retry after DataNodes report blocks."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}