Reputation: 2186
I am trying to connect to a SQL Server-2008 R2 version from my local computer.
I opened my SQL Server Management Studio and entered the server name, user id and password and tried to connect and I get this error:
System.Data.SqlClient.SqlException: '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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)'
This worked fine till 2 days ago. Suddenly, I am getting this type of error. I am confused on the reasons, because every thing was working perfectly.
PS: the SQL Server 2008 R2 is hosted on a Windows Server 2012 Standard edition and my client is a Windows 10 ultimate edition.
Upvotes: 0
Views: 1070
Reputation: 46261
Assuming the SQL Server service is running and the SQL Server Network configuration settings haven't been changed (allowing remote connections via TCP/IP), firewall is the likely culprit.
You can verify TCP/IP port connectivity by running this PowerShell command from the command prompt, specifying the SQL Server host name and the port SQL Server is listing on (default 1433 for default instance). This command will raise and error if port connectivity fails for any reason.
powershell -Command echo ((new-object Net.Sockets.TcpClient).Client.Connect('YourServer', 1433)) 'success'
Also, newer versions of Powershell include Test-NetConnection
(alias tnc
) to facilitate testing TCP port connectivity. Examples:
Test-NetConnection -ComputerName "YourServer" -Port 1433
tnc -ComputerName "YourServer" -Port 1433
tnc "YourServer" -Port 1433
In the case of a non-default or dynamic port (such as a named instance), the port SQL Server is currently using can be determined from SQL Server error log messages. The log will show "Server is listening on" startup messages for the interfaces and ports being used (e.g. "Server is listening on [ 'any' 1433]".
Upvotes: 1