Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Provider named pipes provider error 40 could not open a connection to SQL Server error 2 [duplicate]

Tags:

c#

sql-server

When I am trying to connect to my database in SQL Server Management Studio, I getting this error:

Provider named pipes provider error 40 could not open a connection to SQL Server error

After checking several answers on SO, I opened the SQL Server Configuration Manager

I found SQLSERVER (SQLEXPRESS) and all three options state >> STOPPED

I tried it starting by right clicking on it, but i got below error:

The request failed or the service did not respond in a timely fashion

How can I connect to the instance???

like image 200
C Sharper Avatar asked Dec 27 '13 09:12

C Sharper


4 Answers

Well I have an easy solution for your question. Follow the steps:

  1. Go to SQL Server Configuration manager
  2. SQL Server Network Configuration:
  3. Protocol for MSSQLSERVER
  4. In the right pane split page you will have to disable VIA as follows
    1. Shared Memory - Enable
    2. Named Pipes - Enable
    3. TCP/IP - Enable
    4. VIA - Disable
like image 124
Kailash Sapkota Avatar answered Nov 14 '22 05:11

Kailash Sapkota


Search for services in control panel, there you will find and entry View Local Services in Admin tool section

select it that will show a window with all services in your system, find your service SQLEXPRESS and click on Start. It should start your server instance :)

enter image description here

like image 27
Srinivas Rathikrindi Avatar answered Nov 14 '22 04:11

Srinivas Rathikrindi


In Sql Server Configuration Manager program, start SQL SERVER, enable the TCP/IP connection. After, allow the port in the firewall to be sure that's ok.

like image 2
Ema.H Avatar answered Nov 14 '22 06:11

Ema.H


It's a generic error so it can be a lot of things. I got this error once and when I added port number (1433) to my connection string everything started to work again.

<connectionStrings>
    <add name="ConnectionString" connectionString="Data Source=Server,1433;Initial Catalog=Test;Integrated Security=SSPI;" providerName="System.Data.SqlClient"/>
</connectionStrings>
like image 2
Ogglas Avatar answered Nov 14 '22 05:11

Ogglas