Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not connect to sql server: SQL server Instance failure. (System.Data)

I get this error message when I try to connect to Sql Server

===================================

Cannot connect to **SQL_ServerName**.

===================================

Instance failure. (System.Data)

------------------------------
Program Location:

   at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover, Boolean isFirstTransparentAttempt, SqlAuthenticationMethod authType, Boolean disableTnir)

   ...
like image 235
Justin Lessard Avatar asked Feb 13 '26 03:02

Justin Lessard


2 Answers

The issue was I had two SQL server instance on the same machine.

Both instances were listening to connection on the same port, as describe in this forum

Solution 1: Change one instance to run on another port.

  1. Open your Sql Server Configuration Manager

  2. Go to SQL Server Network Configuration and select Protocols for YOUR_INSTANCE.

  3. Right-click on TCP/IP => Properties

  4. Change the port from 1433 to another one. I changed it to 1434.

  5. Restart sql server and it should work.

Solution 2: Shutdown one sql instance.

  1. Go to services

  2. Find the instance you want to shutdown.

  3. Right-click => Stop

like image 139
Justin Lessard Avatar answered Feb 15 '26 16:02

Justin Lessard


If you have got 2 instances, you take this error. I have MSSQLSERVER and SQL2005 instance name. And after windows server 2008r2 restart, the MSSQLSERVER is working but my default instance SQL2005 is not working. I check the system event log. It says about TCP connection is working another program or service. And I stopped MSSQLSERVER and my default instance SQL2005 started normally... This is port sharing problem.

like image 20
Salih Avatar answered Feb 15 '26 16:02

Salih



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!