This error is only the result, because
HMaster could not be found for some reason, and the specific reason needs to be analyzed.
HMaster failed to start,
HMaster did not register with zookeeper, or registered to the wrong location.
You need to check the
hdfs, and the logs of zookeeper to see if there are any exceptions, and then solve them in a targeted manner.