How to resolve connection refused error while running Hive in Hadoop

Recently, I installed a single-node Hadoop cluster on Ubuntu os after that I tried to add Hive service on top of the Hadoop cluster getting connection refused error in the Hive service. Here is we provided how to resolve the issue with simple steps.

Connection refused error in Hive:

Exception in thread  "main"  java.lang.RuntimeException: call From your domain/ to localhost:8020 failed on connection exception: refused:
at org.apache.hadoop.hive.ql.session.SesseionState.start(
at org.apache.hadoop.hive.cli.CliDriver.main.(
at sum.reflect.NativeMethodAccessorImpl.invoke(Native Method)
Caused by: : Call From  slthupili/ to localhost:8020 failed on connection exception: Connection refused;
at sun.reflect.NativeConstructorAccessorImpl.newInstance0
(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance
at java.lang.reflect.Constructor.newInstance(
Caused by : java.netConnectException: Connection refused
at Method)


Step 1: First, stop all services in Hadoop using below command:


This command used to stop all services like NameNode, DataNode, SecondaryNode, YARN, etc.

Step 2: Start all services, by using below command:


In case, if you are getting the same error try to take backup data then format the name node like below step
Step 3:  Back up the data then will use the below command.  

$ hadoop namenode -format

Above command removes unnecessary data then enter hive command

$ hive

Note: This solution is only applicable for a single node Hadoop cluster without sensitive data

Summary: In this article, we will provide proper resolution for connection refused error in Hive service on top of the Hadoop cluster. Basically, connection refused error is common for Hadoop services so first try to stop the services and start the services. In case if you are getting the same error then remove Hive services and again install it. If you have no data in the cluster and format the Namenode by using the above command for Hadoop Admins/Developers. If you are still facing then comment it, we will check the update on it.