I get the following error when trying to connect to SQL Server:

Cannot connect to

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) (Microsoft SQL Server, Error: 1326)

This error is thrown when I try to configure my database to gridview in Visual Studio 2010. I'm at a loss as to how to debug this error.

How would you debug this error? What steps should I take in order to determine what is really going on here, in addition to the one mentioned in the error message?

6/20/2020 9:12:55 AM

I got Solution for me :

Open "SQL Server Configuration Manager"

Now Click on "SQL Server Network Configuration" and Click on "Protocols for Name"

Right Click on "TCP/IP" (make sure it is Enabled) Click on Properties

Now Select "IP Addresses" Tab -and- Go to the last entry "IP All"

Enter "TCP Port" 1433.

Now Restart "SQL Server .Name." using "services.msc" (winKey + r)

It Will Work...


Adding my heavily upvoted comment as an answer with screenshots.

I spent a lot of time on this, finally what worked for me is:

1) Open Sql Server Configuration Manager --> SQL Server Network configuration --> Protocols for <(INSTANCE)> --> TCP/IP (double click on it).

enter image description here

2) Select --> IP Addresses(Tab).

3) Go to the last entry IP All and mention TCP Port 1433.

enter image description here

4) Press Win+R and enter services.msc.

5) Now restart SQL Server <(INSTANCE)>.

enter image description here

After this, the problem got resolved!


I am solving that problem by opening Services then start running Sql Server (Sqlexpress) service.

service Image


This Error mainly came when the SQL Service is stopped.You need to Restart the service.To go to this window you have to search the Services like this- enter image description here

Then Search for SQLSERVER(MSSQLSERVER) and Restart the service.

enter image description here

Hope this will work.


Press window + R (Run window Open) and in run window type "services.msc" and new services open find SQL SERVER with instance name in my case it's SQL SERVER(SQLEXPRESS) then start this service and try again it works for me Hope Its Works for You also.enter image description here