[Fix] - SQL Server - error Named Pipes Provider, error 40 - Could not open a connection to SQL Server
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.
- Try to ping your own computer from another computer.
- Try disabling firewall / antivirus to arrive at successful pinging.
- 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 :
- Consequently, the connection string must be as “.\SqlExpress" or "<machinename>\Sqlexpress".
- 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:
- Enable Named Pipes : Go to SQL Config Manager -> SQL Server Network Configuration -> Protocols -> Named Pipes -> Right-click -> Enable.
- Restart the server : SQL Config Manager -> SQL Server Services -> SQL Server (SQLEXPRESS) -> Right-click -> Restart.
- Use proper server and instance names
Fix 5 :
Use SERVER\\ INSTANCE NAME with double backslash to resolve the error.
Fix 6 :
- Open SQL Server Configuration Manager.
- Select SQL Server Services from right.
- 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 7.0 OLAP Tools
- SQL Server 2000 64-bit Edition
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