简体   繁体   中英

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

I am trying to deploy a basic .net webform app using azure. it gives me the following error when i try to login in one of the webpages

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

reading various articles on the internet i assume azure cant find the db instance, i tried adding both \ and \ as a prefix to the localmachine\instancename. but it doesnt accept it that way and while setting up connection in the wizard, it wont even list me the db list. it will only accept the machine name

i'd configured the connection string without the instance name to run locally(visual studio, during development) and it runs without any errors and wont take the instance name here as well in the connection string. note: i made a connection string variable in web.config xml file and mention it in my webforms.cs files when required during db connections.

here are the solutions i've tried

-enabling named pipes,tcp/ip(empty dynamic port field in ipall section) -turning off wirewall(public and private) -restarting sqlserver services including agent -running sql server browser (set it up as automatic and runs)

edit: i am deploying with a local sqlserver as db dependency

There are several reasons for getting this error:

  • This is due to failure in connecting to the Sql server instance.
  • SQL Server does not have permission to allow remote connection.
  • Due to firewall settings. Try to follow the below settings:

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.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM