Troubleshoot Apache Hadoop HDFS by using Azure HDInsight

Learn top issues and resolutions when working with Hadoop Distributed File System (HDFS). For a full list of commands, see the HDFS Commands Guide and the File System Shell Guide.

How do I access the local HDFS from inside a cluster?


Access the local HDFS from the command line and application code instead of by using Azure Blob storage or Azure Data Lake Storage from inside the HDInsight cluster.

Resolution steps

  1. At the command prompt, use hdfs dfs -D "" ... literally, as in the following command:

    hdfs dfs -D "" -ls /
    Found 3 items
    drwxr-xr-x   - hdiuser hdfs          0 2017-03-24 14:12 /EventCheckpoint-30-8-24-11102016-01
    drwx-wx-wx   - hive    hdfs          0 2016-11-10 18:42 /tmp
    drwx------   - hdiuser hdfs          0 2016-11-10 22:22 /user
  2. From source code, use the URI hdfs://mycluster/ literally, as in the following sample application:

    import org.apache.hadoop.conf.Configuration;
    import org.apache.hadoop.fs.*;
    public class JavaUnitTests {
        public static void main(String[] args) throws Exception {
            Configuration conf = new Configuration();
            String hdfsUri = "hdfs://mycluster/";
            conf.set("fs.defaultFS", hdfsUri);
            FileSystem fileSystem = FileSystem.get(URI.create(hdfsUri), conf);
            RemoteIterator<LocatedFileStatus> fileStatusIterator = fileSystem.listFiles(new Path("/tmp"), true);
            while(fileStatusIterator.hasNext()) {
  3. Run the compiled .jar file (for example, a file named java-unit-tests-1.0.jar) on the HDInsight cluster with the following command:

    hadoop jar java-unit-tests-1.0.jar JavaUnitTests

Storage exception for write on blob


When using the hadoop or hdfs dfs commands to write files that are ~12 GB or larger on an HBase cluster, you may come across the following error:

ERROR azure.NativeAzureFileSystem: Encountered Storage Exception for write on Blob : example/test_large_file.bin._COPYING_ Exception details: null Error Code : RequestBodyTooLarge
        at java.util.concurrent.Executors$
        at java.util.concurrent.ThreadPoolExecutor.runWorker(
        at java.util.concurrent.ThreadPoolExecutor$
Caused by: The request body is too large and exceeds the maximum permissible limit.
        ... 7 more


HBase on HDInsight clusters default to a block size of 256 KB when writing to Azure storage. While it works for HBase APIs or REST APIs, it results in an error when using the hadoop or hdfs dfs command-line utilities.


Use to specify a larger block size. You can do this modification on a per-use basis by using the -D parameter. The following command is an example using this parameter with the hadoop command:

hadoop -fs -D -copyFromLocal test_large_file.bin /example/data

You can also increase the value of globally by using Apache Ambari. The following steps can be used to change the value in the Ambari Web UI:

  1. In your browser, go to the Ambari Web UI for your cluster. The URL is, where CLUSTERNAME is the name of your cluster. When prompted, enter the admin name and password for the cluster.

  2. From the left side of the screen, select HDFS, and then select the Configs tab.

  3. In the Filter... field, enter

  4. Change the value from 262144 (256 KB) to the new value. For example, 4194304 (4 MB).

    Image of changing the value through Ambari Web UI

For more information on using Ambari, see Manage HDInsight clusters using the Apache Ambari Web UI.


The -du command displays sizes of files and directories contained in the given directory or the length of a file in case it's just a file.

The -s option produces an aggregate summary of file lengths being displayed.
The -h option formats the file sizes.


hdfs dfs -du -s -h hdfs://mycluster/
hdfs dfs -du -s -h hdfs://mycluster/tmp


The -rm command deletes files specified as arguments.


hdfs dfs -rm hdfs://mycluster/tmp/testfile

Next steps

If you didn't see your problem or are unable to solve your issue, visit one of the following channels for more support:

  • Get answers from Azure experts through Azure Community Support.

  • Connect with @AzureSupport - the official Microsoft Azure account for improving customer experience. Connecting the Azure community to the right resources: answers, support, and experts.

  • If you need more help, you can submit a support request from the Azure portal. Select Support from the menu bar or open the Help + support hub. For more detailed information, review How to create an Azure support request. Access to Subscription Management and billing support is included with your Microsoft Azure subscription, and Technical Support is provided through one of the Azure Support Plans.