jerry jose
jerry jose

Reputation: 21

Unable to connect to a remote MS SQL Server and access it's database via. python

I have tried to establish a connection with a remote Microsoft SQL server.

Shown below is the python code I've used to connect to the server.

conn = pyodbc.connect('DRIVER={ODBC Driver 13 for SQL Server};Server=server,1443;DATABASE=master;UID=xx;PWD=xx')

The error shown is as follows:

pyodbc.OperationalError: ('08001', '[08001] [Microsoft][ODBC Driver 13 for SQL Server]TCP Provider: The wait operation timed out.\r\n (258) (SQLDriverConnect); [08001] [Microsoft][ODBC Driver 13 for SQL Server]Login timeout expired (0); [08001] [Microsoft][ODBC Driver 13 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. (258)')

The server is configured to allow remote connections, but it is of no difference. Any help with regards to this problem would be highly appreciated.

Upvotes: 2

Views: 3480

Answers (1)

Deepak Kumar
Deepak Kumar

Reputation: 106

A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible.

The error shows when the server could not be reached or the port might be blocked by the firewall. Can you connect using SQL Server management studio to the MSSQL? If not please check that the server is accepting TCP connections.

This question shows steps to check SQL server settings for the same: https://stackoverflow.com/a/15417069/9135407

Upvotes: 1

Related Questions