Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

hives jdbc connection refused issue

avatar
Super Collaborator

I am running the hive jdbc example with the following connect line :

     Connection con = DriverManager.getConnection("jdbc:hive2://hadoop2.tolls.dot.state.fl.us:10001/default", "", "");

it compiles fine but on run time I get this error :

[hdfs@hadoop1 ~]$ java -cp .:$HADOOP_CLASSPATH:/usr/hdp/2.5.3.0-37/*  HiveAlterRenameTo
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
Exception in thread "main" java.sql.SQLException: Could not open client transport with JDBC Uri: jdbc:hive2://hadoop2.tolls.dot.state.fl.us:10001/default: java.net.ConnectException: Connection refused (Connection refused)
        at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:209)
        at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:107)
  

here is what I have already tried :

1- changed port from 10000 to 10001

2- checked if port is listening and if FW is not blocking it . port is up and listening and not blocked from the client.

[root@hadoop2 hive]# netstat -tnlpa | grep 10000
tcp        0      0 0.0.0.0:10000               0.0.0.0:*                   LISTEN      723/java
tcp        0      0 10.100.44.16:33288          10.100.44.16:10000          TIME_WAIT   -
[root@hadoop2 hive]#

        ... 8 more
[hdfs@hadoop1 ~]$ telnet hadoop2 10000
Trying 10.100.44.16...
Connected to hadoop2.
Escape character is '^]'.
^]
telnet>


7 REPLIES 7

avatar
Master Mentor

@Sami Ahmad

As you are able to telnet "hadoop2" host on port 10000 hence you should alter your code to use the hostname as "hadoop2"

Example:

Connection con = DriverManager.getConnection("jdbc:hive2://hadoop2:10000/default", "", "");

.

On Hive Server2 Host please run the following command to know what is it's actual Hostname (FQDN)

# hostname -f

.

If your client machine where you are running the Hive Client Java code then FQDN of HiveServer2 should be resolvable or else you will have to make changes in your "/etc/hosts" file to make the Hive FQDN resolvable from your client machine.

avatar
Super Collaborator

hi Jay

hostname -f gives

hadoop2.tolls.dot.state.fl.us

and telnet works fine to this FQDN also from hadoop1

[hdfs@hadoop1 ~]$ telnet hadoop2.tolls.dot.state.fl.us 10000
Trying 10.100.44.16...
Connected to hadoop2.tolls.dot.state.fl.us.
Escape character is '^]'.
^]
telnet> quit
[hdfs@hadoop1 ~]$

avatar
Master Mentor

@Sami Ahmad

In your code i see that you are using port 10001 Is that a typo mistake?

Connection con =DriverManager.getConnection("jdbc:hive2://hadoop2.tolls.dot.state.fl.us:10001/default","","");

avatar
Super Collaborator

hi Jay I saw a post on this site advising to use this port since that's the port thrift hive server is using , I tried both , 10000 and 10001 but both fails with connection refused.

avatar
Master Guru
@Sami Ahmad

Port number should be 10000. I see that your Hiveserver2 is listening on 10000.

Can you please double check?

Doc Ref - https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients

Hope this helps.

avatar
Super Collaborator

but I said I used port 10000 and its not working either

what other reasons could be for this error ?

avatar
Contributor

@Sami Ahmad

Please check the metastore and hiveserver2 logs (just to confirm if they started fine or noe). Also, check if the user which fires the connection command has proper permission for the '/user/hive' folder in the hdfs.