Share via

While connecting the SQL server using python script from powershell showing mentioned error

Anandhswarupp 205 Reputation points
2025-02-11T11:11:32.1966667+00:00

Connection failed: ('08001', '[08001] [Microsoft][ODBC Driver 17 for SQL Server]SQL Server Network Interfaces:  (-1983577846) (SQLDriverConnect); [08001] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0); [08001] [Microsoft][ODBC Driver 17 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. (-1983577846)')

SQL Server | Other
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. ZoeHui-MSFT 41,546 Reputation points
    2025-02-12T01:21:06.32+00:00

    Hi @Anandhswarupp,

    When connecting to a SQL Server instance, you may encounter one or more of the following error messages. This article provides some steps to help you troubleshoot these errors, which are provided in order of the issues from simple to complex.

    A network-related or instance-specific error occurred while establishing a connection to SQL Server

    Regards,

    Zoe Hui


    If the answer is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments

  2. Erland Sommarskog 133.6K Reputation points MVP Volunteer Moderator
    2025-02-11T22:49:38.5533333+00:00

    In addition to Olaf's answer, if you are connecting to a named instance, you need to double the backslash.

    0 comments No comments

  3. Olaf Helper 47,616 Reputation points
    2025-02-11T11:18:36.0866667+00:00

    Server is not found or not accessible. Check if instance name is correct

    Mainly as the error message says.

    Can you connect to SQL Server using tools like SSMS with the same credentials?

    0 comments No comments

Your answer

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