Troubleshooting HDFS: Common Errors, Causes and Fixes

Big Data and Hadoop Administrator 16 min min read Updated: Nov 17, 2026 Advanced
Troubleshooting HDFS: Common Errors, Causes and Fixes
Advanced Topic 1 of 3

A Repeatable Diagnosis Flow

  1. What exactly fails? Copy the full error message and time
  2. Scope: one user, one node, one path, or everything?
  3. Recent changes: config, patch, upgrade, network, new job?
  4. Check health: hdfs dfsadmin -report, hdfs fsck /, NameNode UI
  5. Read logs of the NameNode and the affected DataNode around that time
  6. Fix the cause, not the symptom, and write down what you did

Quick Commands

bash hdfs dfsadmin -report | head -25 hdfs dfsadmin -safemode get hdfs haadmin -getAllServiceState hdfs fsck / | tail -20 hdfs fsck /path -files -blocks -locations hdfs getconf -confKey dfs.replication tail -200 /var/log/hadoop/hadoop-hdfs-namenode-$(hostname).log | grep -E "ERROR|WARN|Exception"

Problem 1: NameNode Will Not Start

Log messageCauseFix
java.net.BindException: Address already in useOld process or other service on the portss -ltnp | grep 8020, stop the process
Directory /data/nn1 is in an inconsistent state: storage directory does not exist or is not accessibleMount missing or wrong ownerMount the disk, chown hdfs, check permissions
File system image contains an old layout version / Upgrade requiredBinary version newer than metadataStart with the proper upgrade options
Java heap space / OutOfMemoryErrorHeap too small for namespaceIncrease -Xmx, check block count growth
Edit log corruption / Encountered exception loading fsimageCorrupt metadataCopy the directory, use the other name.dir or the standby, else -recover
Cannot lock storage ... The directory is already lockedA previous NameNode process is still runningKill it or remove in_use.lock only if no process exists

Problem 2: Stuck in Safe Mode

bash hdfs dfsadmin -safemode get grep -i "safe mode" /var/log/hadoop/hadoop-hdfs-namenode-*.log | tail -5 # "The reported blocks 8200 needs additional 800 blocks to reach the threshold 0.9990" hdfs dfsadmin -report | grep -E "Live datanodes|Dead datanodes"
  • Start missing DataNodes, check their logs and networking
  • If many blocks are truly lost, list them with fsck -list-corruptfileblocks before deciding
  • Only after you accept the loss: hdfs dfsadmin -safemode leave, then clean up with fsck -delete or restore from backup

Problem 3: DataNode Does Not Register or Dies

Log messageCauseFix
Incompatible clusterIDsDataNode directories from another (or reformatted) clusterIf the node was reused: clear the data dir after confirming data is not needed, or fix the NameNode ID mismatch
DiskErrorException: Too many failed volumesMore failed disks than failed.volumes.toleratedReplace the disks, reconfigure
java.io.IOException: Too many open filesulimit too lowRaise nofile, restart
Cannot connect to NameNode / Connection refusedFirewall, wrong fs.defaultFS, NameNode downTest with nc -vz nn1 8020, fix configs
Datanode denied communication with namenode because hostname cannot be resolvedReverse DNS missingFix DNS or dfs.namenode.datanode.registration.ip-hostname-check=false (temporary)
Unable to get SASL... / Kerberos errorPrincipal or keytab problemSee Kerberos lesson

Problem 4: Missing and Corrupt Blocks

bash hdfs fsck / -list-corruptfileblocks hdfs fsck /data/sales/orders/part-0001 -files -blocks -locations # find the DataNodes that should have the block and check their logs and disks hdfs debug verifyMeta -meta /data/d1/dn/current/BP-.../current/finalized/subdir0/blk_1073741825_1001.meta -block .../blk_1073741825 # options when no good replica exists hdfs dfs -rm /path/file # delete if it can be reloaded from source hdfs fsck /path -move # move to /lost+found hdfs fsck /path -delete
Recover first: A block may be 'missing' only because the DataNode that has it is down. Bring nodes and disks back before declaring data lost.

Problem 5: Cannot Close File / Lease Issues

A writer crashed and the file stays open for write. Readers may see Cannot obtain block length and MapReduce jobs fail.

bash hdfs fsck /path -openforwrite hdfs debug recoverLease -path /path/to/file -retries 5

Problem 6: Slow Writes and Reads

CheckCommand / metric
One slow DataNode in the pipelineDataNode log Slow BlockReceiver write packet to mirror
Disk latencyiostat -x 5 (await, %util)
Network errorsip -s link, sar -n EDEV 5 3
NameNode overloadedRpcQueueTimeAvgTime, GC pause
Too many xceiversdfs.datanode.max.transfer.threads reached
Under-replicated stormReplication backlog slowing everything

Problem 7: Disk Full

bash hdfs dfsadmin -report | grep -E "DFS Used%|DFS Remaining%" hdfs dfs -du -h -s /user/* | sort -rh | head # who uses the space hdfs dfs -du -h /tmp /app-logs /spark-history /user/*/.Trash | sort -rh | head hdfs dfs -expunge # clear trash hdfs dfs -rm -r -skipTrash /tmp/old_dir hdfs balancer -threshold 5

Problem 8: Permission and Quota Errors

ErrorMeaning and fix
Permission denied: user=alice, access=WRITE, inode=/data:hdfs:hdfs:drwxr-xr-xCheck owner and mode or ACL, group mapping with hdfs groups alice
The DiskSpace quota of /user/alice is exceededRemove files or raise the space quota
The NameSpace quota (directories and files) is exceededToo many files, compact them, raise name quota
org.apache.hadoop.ipc.StandbyExceptionClient hit standby, failover proxy provider missing in config
Failed to replace a bad datanode on the existing pipelineToo few DataNodes for replication during a write, check live nodes and dfs.client.block.write.replace-datanode-on-failure.policy
Keep an incident notebook: Write the symptom, cause and fix of every incident in a shared wiki. The same error returns months later, usually when a different person is on call.

Conclusion

Use a fixed flow, check health commands, then match the error to its cause: bad mounts, metadata, ulimits, DNS, clusterID, missing DataNodes, leases, slow disks, quotas or permissions. Fix the root cause carefully.

Quick Summary: flow: scope -> changes -> health -> logs -> fix cause.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators