I opened up localhost:9870 and try to upload a txt file to the hdfs.
I see the error message below
Failed to retrieve data from /webhdfs/v1/?op=LISTS
Just solved such a problem, I have multiple java versions and hadoop3.1.0.
you need to specify the java home variable in etc/hadoop/hadoop-env.sh, and the java version should be 1.8.