Support Questions
Find answers, ask questions, and share your expertise

Help connecting Hive using CentOS7 ODBC Driver on RHEL 7.3

New Contributor

I have a redhat server 7.3 hosting HDP. I wish to connect python to Hive using an ODBC Driver. The driver I am using is CentOS7 provided by Hortonworks which I learnt from another thread is compatible with RHEL. I followed the setup instructions and tried connecting using a python script tested and working on another box. I keep getting the error, "TTransportException: Could not connect to" I beleive that the connection is timing out. But I'm really stumped so any help is appreciated!

The python script used:

import pyhs2
with pyhs2.connect(host='',
               database='default') as conn:
    with conn.cursor() as cur:
        #Show databases
        print cur.getDatabases()

Traceback of the error message:

TTransportException                       Traceback (most recent call last)
<ipython-input-5-d6450096c810> in <module>()
      6                user='mary',
      7                password='mary',
----> 8                database='default') as conn:
      9     with conn.cursor() as cur:
     10         #Show databases

//anaconda/lib/python2.7/site-packages/pyhs2/__init__.pyc in connect(*args, **kwargs)
      5     """
      6     from .connections import Connection
----> 7     return Connection(*args, **kwargs)

//anaconda/lib/python2.7/site-packages/pyhs2/connections.pyc in __init__(self, host, port, authMechanism, user, password, database, configuration, timeout)
     45         self.client = TCLIService.Client(TBinaryProtocol(transport))
---> 46
     47         res = self.client.OpenSession(TOpenSessionReq(username=user, password=password, configuration=configuration))
     48         self.session = res.sessionHandle

//anaconda/lib/python2.7/site-packages/pyhs2/cloudera/thrift_sasl.pyc in open(self)
     53   def open(self):
     54     if not self._trans.isOpen():
---> 55
     57     if self.sasl is not None:

//anaconda/lib/python2.7/site-packages/thrift/transport/TSocket.pyc in open(self)
     99         message = 'Could not connect to %s:%d' % (, self.port)
    100       raise TTransportException(type=TTransportException.NOT_OPEN,
--> 101                                 message=message)
    103   def read(self, sz):

TTransportException: Could not connect to


@Kate Shaw

Can you check that you can connect to using utilities like nc and telnet?

Super Guru

@Kate Shaw

This looks more of a network than a driver issue. See if you can ping the hive server. If yes, then try opening telnet to port 10000.

From same machine where you are running python program, see if you can connect using a SQL tool or simple Microsoft Excel to connect to Hive to read data.