If you kept default configurations when running hadoop the port for the namenode would be 50070. You will need to find any processes running on this port and kill them first.
Stop all running hadoop with : bin/stop-all.sh
check all processes running in port 50070
sudo netstat -tulpn | grep :50070
#check any processes running in
port 50070, if there are any the / will
appear at the RHS of the output.
sudo kill -9 <process_id> #kill_the_process
.
sudo rm -r /app/hadoop/tmp
#delete the temp folder
sudo mkdir /app/hadoop/tmp
#recreate it
sudo chmod 777 –R /app/hadoop/tmp
(777 is given for this example purpose only)
bin/hadoop namenode –format
#format hadoop namenode
bin/start-all.sh
#start-all hadoop services
Refer this blog