0

I have created an SQL Server on a VM. When I try to connect to my SQL Server on the VM, everything is fine but when I try to connect to it from my desktop via SSMS I have this problem :

A network-related or instance-specific error occurred while establishing a connection to SQL Server. Verify that the instance name is correct and that SQL Server is configured to allow remote connections

I have :
Enabled SQL Server authentication mode
Created a SQL login
Enabled TCP/IP protocol
Enabled firewall rule for the SQL Server port

but still getting the same error.

Dale K
  • 25,246
  • 15
  • 42
  • 71
ikram zouaoui
  • 33
  • 1
  • 4
  • Is the VM "somewhere" else? On what firewall did you enable the SQL port (1433)? – Louis van Tonder Mar 29 '23 at 09:03
  • Well something's missing but it's hard to say what without more information. On which port is the SQL Server instance listening on the VM? Are you trying to connect to a Named Instance (e.g.: `ServerNameOrIpAddress\SomeInstanceNameHere`), or directly to the listening port (e.g.: `ServerNameOrIpAddress,PortNumberHere`)? – AlwaysLearning Mar 29 '23 at 09:09
  • @LouisvanTonder , yes the machine is somewhere else, and I enabled the port by adding an inbound rule in windows defenser firewal and I set the TCP/IP sql server port to 1433 and I enabled it then I checked the distant connexion in my sql server and it is enabled too – ikram zouaoui Mar 29 '23 at 09:09
  • On the machine with SSMS, are you able to open a PowerShell window and run `Test-NetConnection -ComputerName ServerNameOrIpAddressHere -Port 1433` (or whatever the listening port number is) and get successful ping and connection results? – AlwaysLearning Mar 29 '23 at 09:11
  • Depending on where your VM is hosted, you need to make sure that it is accessible from the "outside". Setting rules on the windows firewall wont help if there is a firewall in place with the hosting company, before it reaches your box. – Louis van Tonder Mar 29 '23 at 09:12
  • @AlwaysLearning ComputerName : IpAddressHere RemoteAddress : IpAddressHere RemotePort : 1433 InterfaceAlias : Ethernet0 SourceAddress : IpAddressHere TcpTestSucceeded : True – ikram zouaoui Mar 29 '23 at 09:17
  • @LouisvanTonder I suspected the same reason , I will check with the administrator of the VM – ikram zouaoui Mar 29 '23 at 09:19

0 Answers0