Support Questions
Find answers, ask questions, and share your expertise
Announcements
Check out our newest addition to the community, the Cloudera Innovation Accelerator group hub.

Unable to connect to beeline

Hello,


I am not able to connect to beeline. It is throwing error as "connection refused". I was able to see hive server2 service and hive metastore service is up and running through ambari UI. I am using the below command to connect

beeline -u 'jdbc:hive2://headnodehost:10001/;transportMode=http'

below is the error:


Connecting to jdbc:hive2://headnodehost:10001/;transportMode=http
	19/06/07 22:44:46 [main]: ERROR jdbc.HiveConnection: Error opening session
	org.apache.thrift.transport.TTransportException: org.apache.http.conn.HttpHostConnectException: Connect to headnodehost:10001 [headnodehost/10.0.0.14] failed: Connection refused (Connection refused)
	at org.apache.thrift.transport.THttpClient.flushUsingHttpClient(THttpClient.java:297)
	at org.apache.thrift.transport.THttpClient.flush(THttpClient.java:313)
	at org.apache.thrift.TServiceClient.sendBase(TServiceClient.java:73)
	at org.apache.thrift.TServiceClient.sendBase(TServiceClient.java:62)
	at org.apache.hive.service.cli.thrift.TCLIService$Client.send_OpenSession(TCLIService.java:158)
	at org.apache.hive.service.cli.thrift.TCLIService$Client.OpenSession(TCLIService.java:150)
	at org.apache.hive.jdbc.HiveConnection.openSession(HiveConnection.java:622)
	at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:221)
	at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:105)
	at java.sql.DriverManager.getConnection(DriverManager.java:664)
	at java.sql.DriverManager.getConnection(DriverManager.java:208)
	at org.apache.hive.beeline.DatabaseConnection.connect(DatabaseConnection.java:146)
	at org.apache.hive.beeline.DatabaseConnection.getConnection(DatabaseConnection.java:211)
	at org.apache.hive.beeline.Commands.connect(Commands.java:1204)
	at org.apache.hive.beeline.Commands.connect(Commands.java:1100)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.hive.beeline.ReflectiveCommandHandler.execute(ReflectiveCommandHandler.java:54)
	at org.apache.hive.beeline.BeeLine.dispatch(BeeLine.java:998)
	at org.apache.hive.beeline.BeeLine.initArgs(BeeLine.java:717)
	at org.apache.hive.beeline.BeeLine.begin(BeeLine.java:779)
	at org.apache.hive.beeline.BeeLine.mainWithInputRedirection(BeeLine.java:493)
	at org.apache.hive.beeline.BeeLine.main(BeeLine.java:476)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.hadoop.util.RunJar.run(RunJar.java:243)
	at org.apache.hadoop.util.RunJar.main(RunJar.java:158)
	Caused by: org.apache.http.conn.HttpHostConnectException: Connect to headnodehost:10001 [headnodehost/10.0.0.14] failed: Connection refused (Connection refused)
	at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:151)
	at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
	at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
	at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
	at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
	at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
	at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
	at org.apache.http.impl.execchain.ServiceUnavailableRetryExec.execute(ServiceUnavailableRetryExec.java:84)
	at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:117)
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
	at org.apache.thrift.transport.THttpClient.flushUsingHttpClient(THttpClient.java:251)
	... 30 more
	Caused by: java.net.ConnectException: Connection refused (Connection refused)
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:589)
	at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:74)
	at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134)
	... 41 more
	Error: Could not establish connection to jdbc:hive2://headnodehost:10001/;transportMode=http: org.apache.http.conn.HttpHostConnectException: Connect to headnodehost:10001 [headnodehost/10.0.0.14] failed: Connection refused (Connection refused) (state=08S01,code=0)
	Beeline version 1.2.1000.2.6.5.3005-23 by Apache Hive
13 REPLIES 13

Mentor

@Nani Bigdata

Please could you try this different approach, invoke the beeline as user hive

$ beeline
Beeline version 0.14.0.2.2.7.1-10 by Apache Hive
beeline> !connect jdbc:hive2://headnodehost:10001/;transportMode=http admin

Hope that helps

Hi Geoff, it is asking password to enter while I am using 'beeline> !connect jdbc:hive2://headnodehost:10001/;transportMode=http admin'

Does this have different password

Super Mentor

@Nani Bigdata

Few additional checks:


1. On the HiveServer2 host can you check which all ports it has opened and listening to? You can run the following command to findout the ports used.

# netstat -tnlpa | grep `cat /var/run/hive/hive-server.pid`


1(A). Also from any of the Cluster node try to check if you are able to access the HS2 and port 10001 using telnet or netcat to verify any port blocking/network issue? (From beeline run the following command)

 # telnet 10.0.0.14 10001
 # telnet headnodehost 10001
(OR)
 # nc -v  10.0.0.14 10001
 # nc -v  headnodehost 10001



2. If you are not able to see the port "10001" then then you will need to check the hive configs and the Hive Logs to find out if there are any errors?


3. Also can you double check your Hive Config to find out if it is actually set for "http" mode or "binary" mode in the following property: "hive.server2.transport.mode"


4. In your HS2 connection URL i see that you are missing the "httpPath". Can you please try adding the "httpPath" there something like following and then see if that works? You can find the httpPath value from your HS2 configurations by looking at the property "hive.server2.thrift.http.path"

Example:

# beeline -u "jdbc:hive2://headnodehost:10001/default;transportMode=http;httpPath=cliservice

.

5. For troubleshooting purpose try connecting to beeline in Interactive mode as suggested by @Geoffrey Shelton Okot to verify that you are able to connect to HS2 or not at an alternate option?


Side note:

You can also try to connect the HS2 using the Dynamic discovery mode something as described in the doc: https://docs.hortonworks.com/HDPDocuments/HDP3/HDP-3.1.0/fault-tolerance/content/dynamic_service_dis...

Ambari UI --> Hive --> Summary (Tab) --> "HiveServer2 JDBC URL" --> Click on the at the right side of the URL to copy the URL and then try this URL with beeline once.

.

.


Thank you. I completed step 1. (netstat -tnlpa | grep `cat /var/run/hive/hive-server.pid`) but could not find 10001. Trying to figure out the logs. Appreciate if you can share me the location of logs( hive configs and the Hive Logs). Also I was ale to connect through beeline 5 days back but not it is not letting me.

Also tried this step (Ambari UI --> Hive --> Summary (Tab) --> "HiveServer2 JDBC URL" --> Click on the at the right side of the URL to copy the URL and then try this URL with beeline once.) but it is showing no such file or directory found

For 1(a) this is the response " Unable to connect to remote host: Connection refused"

Thank you Geoff. Beeline command not found is the error.


Mentor

@Nani Bigdata
Please can you share the screenshot of the command line snippet


Thank you Geoff. Please find the screen as attached. seems I am executing improperly.



Super Mentor

@Nani Bigdata

As you mentioned that "netstat" command itself is not showing that the port 10001 is opened then definitely you can not connect to it using "beeline" or "telnet" utilities.

Check the following and then try to provide us as much information which we requested in previous post. All the command outputs and the configs which we requested you to check.


Check-1). Hence please check your HiveServer2 log first to find out what might be wrong? Please restart HS2 and then collect a fresh log from "/var/log/hive/hiveserver2.log"

Check-2). What is the value of following hive properties?

"hive.server2.transport.mode"

"hive.server2.thrift.http.path"

Check-3). Please share the output of the following (or screenshot of the exact error)

Ambari UI --> Hive --> Summary (Tab) --> "HiveServer2 JDBC URL" --> Click on the at the right side of the URL to copy the URL and then try this URL with beeline once.

As you mentioned that you got "no such file or directory found." So please share the complete output of the error .


Check-4). May be your "hive.server2.transport.mode" is set to "binary" (default value) so in that case please check if the following approach works on port 10000 (instead of http mode 10001).

# beeline -u "jdbc:hive2://headnodehost:10000/default"

.

Super Mentor

@Nani Bigdata

Earlier you mentioned that you could not find port 10001 being opened. Hence you were getting "(Connection refused) (state=08S01,code=0)" error.

# netstat -tnlpa | grep `cat /var/run/hive/hive-server.pid`   


Now if you are curently able to see that Port 10001 is listening then in that case you can try to login using default "hive" / "hive" to see if it works? Ideally any valid user who has access to Hive DB should be able to connect via beeline.

.


If you still face any error then please share the complete stack trace of the error.

Also if your current issue is different from the Originally reported issue "(Connection refused) (state=08S01,code=0)" then please open a separate HCC thread and mark this HCC thread as answered by clicking on the "Accept" button on correct/helpful answer.

Thank you.As mentioned earlier netstat -tnlpa | grep `cat /var/run/hive/hive-server.pid` itself is not showing port 10001. Below is the error stack



ERROR jdbc.HiveConnection: Error opening session
org.apache.thrift.transport.TTransportException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:10001 [localhost/127.0.0.1] failed: Connection refused (Connection refused)
at org.apache.thrift.transport.THttpClient.flushUsingHttpClient(THttpClient.java:297)
at org.apache.thrift.transport.THttpClient.flush(THttpClient.java:313)
at org.apache.thrift.TServiceClient.sendBase(TServiceClient.java:73)
at org.apache.thrift.TServiceClient.sendBase(TServiceClient.java:62)
at org.apache.hive.service.cli.thrift.TCLIService$Client.send_OpenSession(TCLIService.java:158)
at org.apache.hive.service.cli.thrift.TCLIService$Client.OpenSession(TCLIService.java:150)
at org.apache.hive.jdbc.HiveConnection.openSession(HiveConnection.java:622)
at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:221)
at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:105)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:208)
at org.apache.hive.beeline.DatabaseConnection.connect(DatabaseConnection.java:146)
at org.apache.hive.beeline.DatabaseConnection.getConnection(DatabaseConnection.java:211)
at org.apache.hive.beeline.Commands.connect(Commands.java:1204)
at org.apache.hive.beeline.Commands.connect(Commands.java:1100)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.hive.beeline.ReflectiveCommandHandler.execute(ReflectiveCommandHandler.java:54)
at org.apache.hive.beeline.BeeLine.dispatch(BeeLine.java:998)
at org.apache.hive.beeline.BeeLine.initArgs(BeeLine.java:717)
at org.apache.hive.beeline.BeeLine.begin(BeeLine.java:779)
at org.apache.hive.beeline.BeeLine.mainWithInputRedirection(BeeLine.java:493)
at org.apache.hive.beeline.BeeLine.main(BeeLine.java:476)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.hadoop.util.RunJar.run(RunJar.java:243)
at org.apache.hadoop.util.RunJar.main(RunJar.java:158)
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to localhost:10001 [localhost/127.0.0.1] failed: Connection refused (Connection refused)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:151)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.execchain.ServiceUnavailableRetryExec.execute(ServiceUnavailableRetryExec.java:84)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:117)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
at org.apache.thrift.transport.THttpClient.flushUsingHttpClient(THttpClient.java:251)
... 30 more
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:74)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134)
... 41 more
Error: Could not establish connection to jdbc:hive2://localhost:10001/;transportMode=http: org.apache.http.conn.HttpHostConnectException: Connect to localhost:10001 [localhost/127.0.0.1] failed: Connection refused (Connection refused) (state=08S01,code=0)