1

When I try to connect to SQL database from another computer using SQL Server Management Studio with Server Name [ my_ip_address,1433\MyServerName ] and SQL authentication, I get this error:

Cannot connect to XX.XXX.XXX.XXX,1433\MyServerName.

ADDITIONAL INFORMATION: 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 wait operation timed out.) (Microsoft SQL Server, Error: 258)

The wait operation timed out

I have done all of the needed steps:

  • Allowed remote connection in Server Properties window in SQL Management Studio
  • Enabled TCP/IP in SQL Configuration Manager (in SQL Server Network Configuration)
  • Set Inbound/Outbound enable connection (Domain, public, private) rules in Windows Firewall for ports TCP 1433
Dale K
  • 25,246
  • 15
  • 42
  • 71
Arij Bt
  • 23
  • 7
  • Does this answer your question? [Why am I getting “Cannot Connect to Server - A network-related or instance-specific error”?](https://stackoverflow.com/questions/18060667/why-am-i-getting-cannot-connect-to-server-a-network-related-or-instance-speci) – Thom A May 11 '21 at 09:28
  • 1
    `my_ip_address,1433\MyServerName` would try to connect to a server called "my_ip_address,1433", *not* port 1433 on the server with the IP `my_ip_address`. It would be `YourServerName\InstanceName,1433`; though port 1433 is the default, so isn't needed. – Thom A May 11 '21 at 09:29
  • @Larnu I tried all of that. for YourServerName\InstanceName,1433 it did not work either – Arij Bt May 11 '21 at 09:58
  • But have you corrected your connection string..? – Thom A May 11 '21 at 09:59
  • @Larnu yes I did – Arij Bt May 11 '21 at 09:59
  • So what is the latest error you get, after correcting the string? – Thom A May 11 '21 at 10:00
  • If you changed any of the instance's network settings in SQL Server Configuration Manager you need to stop and start the SQL Server service for the changes to take effect. – AlwaysLearning May 11 '21 at 10:05
  • @AlwaysLearning I restart the service on every change I make – Arij Bt May 11 '21 at 10:06
  • Try removing the instance name from your connection string and just use `XX.XXX.XXX.XXX,1433` instead. When you specify an instance name the client must first connect to the SQL Browser service on udp/1434 to resolve the instance name to a TCP port number. Since you already know the TCP port number you can bypass that whole process. – AlwaysLearning May 11 '21 at 10:12
  • 1
    Start over and start with the basics. Did you install SQL Server Express or a different edition? Did you install the server instance as the default instance or as a named instance? Did you assign a static port? Look in the sql server error log and you will see the port that it is listening on. That is the port number you need to supply if you assigned a static port. And as already mentioned, you connect to either the instance name alone (servername\instance - no port) or to the servername,port. Not both. – SMor May 11 '21 at 10:44
  • @AlwaysLearning I tried that too. – Arij Bt May 11 '21 at 11:10
  • @SMor , on the first pc sqlsever developer edition is installed and in the second computer sql server express edition is installed, I am trying to connect from the second computer on the server of the first one – Arij Bt May 11 '21 at 11:10
  • Your second instance is not relevant here, so let's not add confusion. Did you, in fact, install a default or named instance on the first PC? And did you verify what port it is using as I suggested? Is the SQL Server Browser service running on the first PC? In the sql server error log you will also find messages about what protocols are enabled. – SMor May 11 '21 at 12:03

1 Answers1

1

This tuto solved the problem for me: Allow SQL Server through Windows Firewall ( https://www.youtube.com/watch?v=3jVTUll4PXs) I had to add the paths of the sql server and sql server browser services to the allowed apps by the firewall.

Arij Bt
  • 23
  • 7