Share via

Cannot connect Excel to SQL Server 22

Dave Kempsell 5 Reputation points
2024-03-01T11:42:30.7+00:00

I am trying to connect to my SQL Server 22 database with Microsoft Excel. I have connected to it through a javascript application using the mssql library, and therefore know it is allowing TCP connections. But I get this error message when I try and connect using the excel connection wizard:

Unable to connect

We encountered an error while trying to connect.

Details: "Microsoft SQL: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - The remote computer refused the network connection.)"

I'm wondering if it's a windows firewall issue? I don't have full administrator access on the machine I'm using, could that be the problem?

Microsoft 365 and Office | Excel | For business | Windows
SQL Server | Other
0 comments No comments

4 answers

Sort by: Most helpful
  1. Dan Guzman 9,516 Reputation points
    2024-03-01T14:52:15.99+00:00

    I'm wondering if it's a windows firewall issue? I don't have full administrator access on the machine I'm using, could that be the problem?

    The connection error could be due to a firewall or name resolution issue. For troubleshooting, an easy way to test TCP port connectivity from the client machine is with the Powershell Test-NetNetConnection command. Below is an example you can run from a Windows command prompt.

    powershell -Command "tnc "YourServer" -Port 1433"

    1 person found this answer helpful.
    0 comments No comments

  2. Srikar Gondesi - UAS Database Administrator 85 Reputation points
    2024-03-04T10:53:44.93+00:00

    Hi @Dave Kempsell

    does ping and telnet test work to target SQL machine name/IP from the server where you have excel?
    if both are on same server, check if you are using the right server\instance name.

    Are you using a dynamic port? then you need to open access to the entire dynamic port range in Firewall. If using static port, try the below troubleshooting steps.

    Is your SQL server a named instance?
    which provider/driver are you using to connect to SQL from XL? Use the same provider and do a UDL test from the same server where your XL is present.

    could be a firewall issue also as you mentioned as per the error message((provider: TCP Provider, error: 0 - The remote computer refused the network connection.)).

    on SQL machine, open SSMS and try to force TCP/IP connection.
    tcp:servername,portNumber

    0 comments No comments

  3. ZoeHui-MSFT 41,551 Reputation points
    2024-03-04T02:19:38.6666667+00:00

    Hi @Dave Kempsell,

    It is a general error message.

    Microsoft SQL: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - The remote computer refused the network connection.

    You may follow the official documentation to troubleshoot.

    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

  4. Erland Sommarskog 133.7K Reputation points MVP Volunteer Moderator
    2024-03-01T22:43:05.3033333+00:00

    The error message means that you were not able to connect to the SQL Server instance you had specified. There can be any number of reasons for that:

    • SQL Server is not running.
    • The machine or instance name is misspelled.
    • A firewall is blocking the way.
    • The Browser service is not running.
    • And the list goes on.

    Here is a link to a troubleshooter you can try.

    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.