This guide shows how to troubleshoot HDFS with practical, copy-pasteable steps. You will learn to read the right logs, run safe commands, isolate causes, and execute step-by-step recovery workflows for common failures. Keep this as a runbook for developers, DevOps consultants, and startup teams running data lakes or Hadoop-backed services.
Workflow Overview
Use this flow during incidents:
- Quick triage to capture the state without changing it.
- Identify the failure domain: client, NameNode, DataNode, network, auth, or filesystem.
- Run targeted diagnostics for that domain.
- Apply the lowest-risk fix first and verify.
- Escalate to deeper recovery steps only if needed.
- Record commands and outcomes so you can repeat or roll back.
Quick Triage
Start with non-destructive checks.
- Verify processes:
- On NameNode and DataNodes:
jps - Inspect cluster state:
hdfs dfsadmin -report- Scan for block issues:
hdfs fsck / -blocks -locations -racks -openforwrite- List recent operations in a path:
hdfs dfs -ls -R /path-of-interest | tail -n 50- Tail logs:
tail -F $HADOOP_LOG_DIR/hdfs/NameNode.logtail -F $HADOOP_LOG_DIR/hdfs/DataNode.loggrep -Ei 'ERROR|FATAL|Exception' $HADOOP_LOG_DIR/hdfs/*.log
Capture symptoms before restarting anything.
NameNode Issues
Symptoms:
- Clients hang on list or create.
- Web UI unavailable or shows Safe Mode.
- Exceptions like:
org.apache.hadoop.hdfs.server.namenode.SafeModeException: Cannot create file ... Name node is in safe mode
What to do, step-by-step:
- Check safe mode:
hdfs dfsadmin -safemode get- If ON due to low block replication, fix block health first (see replication section), then:
hdfs dfsadmin -safemode leave.
- Verify NameNode process and ports:
jpsshould showNameNode.netstat -plnt | grep -E '8020|50070|9870'- If a port is in use, stop the conflicting process or change the bind address.
- Check disk on NameNode metadata dirs (fsimage, edits):
df -h- Ensure free space; avoid letting metadata disks hit 100%.
- Review NameNode logs:
- Look for
JournalNodeconnectivity errors, failed shared edits, orjava.io.IOException: No space left on device.
- If NameNode will not start:
- Confirm
core-site.xmlandhdfs-site.xml(e.g.,fs.defaultFS,dfs.namenode.name.dir,dfs.namenode.edits.dir).
- Do not format production metadata:
- Never run
hdfs namenode -formaton a live metadata directory.
- If using JournalNodes:
- Ensure all JournalNodes are up; check port 8485 and their logs.
- Validate after recovery:
hdfs dfsadmin -report- Open the NameNode web UI and confirm live DataNodes and block health.
DataNode & Replication
Symptoms:
- Slow reads/writes limited to certain hosts.
UNDER_REPLICATEDorMISSINGblocks.- DataNode logs show
Volume failedor disk I/O errors.
Recovery workflow:
- Cluster view:
hdfs dfsadmin -reportto see Live/Dead decommissioning status and capacity.
- Identify bad blocks:
hdfs fsck / -blocks -locations -racks | grep -i 'Under replicated\|Missing'
- Trigger replication for a path:
hdfs dfs -setrep -w 3 /data/critical- The
-wwaits until target replication is met.
- If many nodes are dead:
- Check network/firewall rules and DataNode logs for disk failures.
- Verify DataNode data dirs:
dfs.datanode.data.dirshould exist, be writable by the DataNode user, and have free space.
- Decommissioning stuck:
- Update exclude file, then
hdfs dfsadmin -refreshNodes. - Ensure target replication can be satisfied before final removal.
- Rebalance after adding capacity:
hdfs balancer -threshold 10- Monitor and pause if it impacts jobs.
- Confirm block health:
hdfs fsck / -blocks | grep -v 'Under replicated'
Disk & Permissions
Disk full or permission issues often cause cascading failures.
Disk space (OS level):
df -hon NameNode and DataNodes.du -sh /hadoop/dfs/*to find large dirs.- Rotate or gzip large logs.
- DataNode logs may show
No space left on deviceor too many failed volumes. Free space, add capacity, or adjustdfs.datanode.failed.volumes.toleratedwith care.
HDFS usage and quotas:
hdfs dfs -du -h -s /projects/teamXhdfs dfs -count -q -h /projects/teamX- Trash cleanup when safe:
hdfs dfs -expunge - Consider
fs.trash.intervalfor automated trash behavior.
Permissions:
- Inspect and fix:
hdfs dfs -ls -R /pathhdfs dfs -chown -R user: group /pathhdfs dfs -chmod -R 755 /path- For shared temp dirs, use sticky bit 1777 where appropriate.
- Ensure service users own and can write to their working dirs.
Network & RPC
Network problems lead to timeouts, dead nodes, and flaky clients.
- DNS and reachability:
getent hosts namenode.example.comping -c 3 namenode.example.com- Ensure reverse DNS resolves to the same FQDN.
- Required ports:
nc -vz namenode 8020nc -vz datanode 50010- Also check 50070 or 9870 (HTTP/HTTPS), and 9864 or 50075 (DataNode web).
- Open firewalls accordingly.
- Client timeouts:
- Look for
CallTimeoutExceptionin client logs. - Consider tuning
dfs.client.socket-timeoutandipc.client.connect.max.retriesfor unstable links.
- Correct NameNode address:
fs.defaultFSincore-site.xmlshould matchhdfs://clusterand point to the active NameNode.
- Rack awareness:
- Ensure topology scripts are present and executable across nodes, if used.
Kerberos Auth
Auth failures present as SASL or GSS errors.
Common errors:
GSS initiate failedFailed to find any Kerberos tgtClient cannot authenticate via SASL
Recovery steps:
- Get a valid ticket:
kinit -kt /etc/security/keytabs/hdfs.headless.keytab hdfs/host@REALM- Verify:
klist
- Fix clock skew:
chronyc trackingorntpstat; keep drift small (ideally under 5 minutes).
- Validate principals and keytabs:
- Service configs often use
_HOST, e.g.,hdfs/_HOST@REALM. - Ensure keytabs match the host FQDN.
- Confirm Kerberos settings:
hadoop.security.authenticationset tokerberosincore-site.xml.- JAAS and keytab files readable by the service user.
- Host-specific issues:
- Regenerate the host keytab, restart only the affected service, and re-test with
hdfs dfs -ls /.
Safe Commands
Read-only or low-risk commands to prefer early:
- Cluster state:
hdfs dfsadmin -reporthdfs fsck / -blocks -locations -racks -openforwrite- Files and quotas:
hdfs dfs -ls -R /pathhdfs dfs -du -h -s /pathhdfs dfs -count -q -h /path- Process and ports:
jpsnetstat -plnt | grep -E '8020|50010|50070|9870|9864|8485'ss -lptn- Logs:
tail -F $HADOOP_LOG_DIR/hdfs/*grep -Ei 'ERROR|FATAL|SASL|Under replicated|SafeMode' $HADOOP_LOG_DIR/hdfs/*.log- Network:
getent hosts hostnslookup hostnc -vz host portcurl -I http://namenode:9870/- Kerberos:
klistkinit -Rkvno hdfs/host@REALM
Local Pilot Plan
Prove this workflow safely on one host or a small test cluster.
Scope: validate triage and two recovery paths (safe mode exit and under-replicated fix).
- Baseline health:
hdfs dfsadmin -reporthdfs fsck / -blocks
- Safe mode drill:
- In a test setup, cause safe mode by temporarily reducing replication tolerance or by stopping a test DataNode.
- Observe
hdfs dfsadmin -safemode getand relevant NameNode logs. - Bring capacity back and exit:
hdfs dfsadmin -safemode leave.
- Under-replication drill:
- Create a small file:
hdfs dfs -put README /tmp/ hdfs dfs -setrep -w 3 /tmp/READMEon a cluster with 3 DNs; watch replication complete.- Verify with
hdfs fsck /tmp/README -blocks -locations.
- Kerberos drill (if enabled):
kinit -kt ...andklist.- Expire the TGT or wait; observe failures; renew and re-test.
- Record commands and timings so the team can run the same steps consistently.
Conclusion
Effective HDFS troubleshooting follows a predictable pattern: triage with safe reads, isolate the failing domain, apply targeted diagnostics, and use the lowest-risk recovery that addresses root cause. Start with the pilot plan to build team muscle memory. As next steps, keep a short checklist of safe commands, track common log signatures for your environment, and practice one scenario per sprint so incidents become routine to resolve.