Unable To Connect to Azure SQL on Redhat VM but working on Windows Machine

Nayak, Tirthankar 1 Reputation point
2020-11-02T17:28:35.87+00:00

Code in Python

import pyodbc
server = '<SERVER_NAME>.database.windows.net'
database = '<DB_NAME>'
username = '<USER>@<DOMAIN>.com'
password = '<PASSWORD>'
authentication = 'ActiveDirectoryPassword'
driver= '{ODBC Driver 17 for SQL Server}'

cnxn = pyodbc.connect('DRIVER='+driver+';SERVER='+server+';DATABASE='+database+';UID='+username+';Authentication='+authentication+';PWD='+password)
cursor = cnxn.cursor()
cursor.execute("SELECT @@version;")
row = cursor.fetchone()
while row:
print(row[0])
row = cursor.fetchone()

Error Info on RedHat VM (version 7.2)

Traceback (most recent call last):
File "sample.py", line 9, in <module>
cnxn = pyodbc.connect('DRIVER='+driver+';SERVER='+server+';DATABASE='+database+';UID='+username+';Authentication='+authentication+';PWD='+password)
pyodbc.OperationalError: ('HYT00', '[HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')

The Same piece of Code runs on Windows Machine.
Both have Odbc 17 installed and using 'pyodbc' python library to connect to Database.

Can you please look into this matter ASAP?

Thank You

Azure SQL Database
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Anurag Sharma 17,631 Reputation points
    2020-11-04T10:29:08.093+00:00

    Hi @Nayak, Tirthankar , welcome to Microsoft Q&A forum.

    Could you please check if you are able to connect from SQL Authentication instead of Active Directory Password once?

    Also, please check if public ip of machine has been added to firewall rule.


  2. Rupesh Agarwal 1 Reputation point
    2021-05-17T16:39:28.89+00:00

    any leads on this ?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.