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/127.0.1.1 to localhost:8020 failed on connection exception: Java.net.ConnectionException:Connection refused:
at org.apache.hadoop.hive.ql.session.SesseionState.start(SessionStart.java:522)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:677)
at org.apache.hadoop.hive.cli.CliDriver.main.(CliDriver.java:621)
at sum.reflect.NativeMethodAccessorImpl.invoke(Native Method)
...more
Caused by: java.net.ConncetException : Call From  slthupili/127.0.1.1 to localhost:8020 failed on connection exception: java.net.ConnectionException: Connection refused;
at sun.reflect.NativeConstructorAccessorImpl.newInstance0
(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance
(NativeConstructorAccessorImple.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance
(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
...more
Caused by : java.netConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannel Impl.java:717)
at org.apache.hadoop.net.NetUtilis.connect(NetUtils.java:530)
...more

Solution:





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

$ stop-all.sh

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

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

$start-all.sh

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.