[Fix] - SQL Server - error Named Pipes Provider, error 40 - Could not open a connection to SQL Server

Wikitechy | 3545 Views | sql server | 05 Jun 2016

 

Scenario :

When trying to connect to a database from a site the below error occurs:

Named Pipes Provider, error: 40 - Could not open a connection to SQL Server

Fix 1 :

Basic checks to be done for this error:

  • Named pipe/TCP is enabled.
  • Remote connections are allowed.
  • Windows Firewall is off.


  1.     Try to ping your own computer from another computer. 
  2.     Try disabling firewall / antivirus to arrive at successful pinging.
  3.     Under windows Firewall create an exception for port 1433 as follows:

Go to Control Panel -> Click on Windows Firewall -> Go to exception tab as shown below. 

 

    4.   Click on Add Port... and enter the port number and name.

 

    5.   Click on Add Program -> Add C:\Program Files\Microsoft SQL Server\90\Shared location\SQLBrowser.exe in exception list.

 

    6.     Click ok and save the changes. 

Fix 2 :

Go to control panel -> Open Local services window -> select MSSQLSERVER service and restart.

( Or )

Go to run -> services.msc -> right click on SQL Server name and select “Restart” as shown below:


Fix 3 :

Check for the backslash or forward slash usage with SERVER_NAME/INSTANCENAME.

Fix 4 :

  1.     Consequently, the connection string must be as “.\SqlExpress" or "<machinename>\Sqlexpress".
  2.     Named Pipes may be disabled by default after installing SqlExpress.c. If Sqlexpress is installed with the remote machine, enable remote connection for Express.

Named Pipes :

Follow three a step process after installing SQL Serve r:

  1.     Enable Named Pipes : Go to SQL Config Manager -> SQL Server Network Configuration -> Protocols -> Named Pipes -> Right-click -> Enable.
  2.     Restart the server : SQL Config Manager -> SQL Server Services -> SQL Server (SQLEXPRESS) -> Right-click -> Restart.
  3.     Use proper server and instance names 

Fix 5 :

Use SERVER\\ INSTANCE NAME with double backslash to resolve the error.

Fix 6 :

  1.     Open SQL Server Configuration Manager.
  2.     Select SQL Server Services from right.
  3.     Find your server and go to its properties (with right click)

Change log on method to Local System as shown below:

 

Fixes are applicable to the following versions of SQL Server:

  • SQL Server 1.1 (16 bit)
  • SQL Server 4.2A (16 bit)
  • SQL Server 4.2B (16 bit)
  • SQL Server 4.21a
  • SQL Server 6.0
  • SQL Server 6.5
  • SQL Server 7.0
  • SQL Server 7.0 OLAP Tools
  • SQL Server 2000
  • SQL Server 2000 64-bit Edition
  • SQL Server 2005
  • SQL Server 2008
  • Azure SQL DB
  • SQL Server 2008 R2
  • SQL Server 2012
  • SQL Server 2014
  • SQL Server 2016

Related Error Tags :

  • Resolving could not open a connection to SQL Server errors
  • Could not open a connection to SQL Server 
  • How to Fix named Pipes Provider Error 40
  • provider: Named Pipes Provider, error: 40