When we try to connect to the
SQL Server, many times we get an
Error as
Provider: Named Pipes Provider, Error: 40 – could not open a connection to SQL server.
Reasons for getting this error are:
- This is due to failure in connecting to the server instance we are using.
- The wrong default settings.
- SQL Server does not have permission to allow remote connection.
- Due to firewall settings.
Follow the below given solutions to resolve these issues:
1.
SQL Server instance is not running.
Go to
Services option, click on
SQL Server installed in your system, I have SQL Server instance installed with name:
MSSQLSERVER. If it is in
not Started Status, then start it by right clicking on it and click on
START option.
2.
Make sure that TCP/IP is enabled.
To make it enable follow the steps: Click on
Configuration Manager of SQL Server.
Now you can check the
TCP/IP port status as
Enabled or
Disabled. You need to make it
Enable and click on status to change port
Properties.
Now fill
Default Port no 1433 click on
OK button.
3. Allow Remote Connections enabled under Connections in SQL Server Properties:
Follow the below given steps to enable it.
First open SQL Management Studio then right click on the server name and click on the server Properties.
In the Server Properties under the Connections Options, you need to check the box of Allow remote connections to this server and then click on Ok button.
4. Allow SQL Server in Firewall Settings: You need to add a Windows Firewall exception on the server for SQL TCP ports 1433 and 1434, so that SQL Server will run.
Go to Control Panel then System and Security or directly search it on you system search as Windows Firewall in this click on Firewall, Here you can see Action tab as Allow for Firewall. You can change it through SQL Server Properties to allow or block. As given in the below image.