Why am I getting “Cannot Connect to Server - A net

2018-12-31 00:14发布

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

Cannot connect to 108.163.224.173.

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?

30条回答
弹指情弦暗扣
2楼-- · 2018-12-31 01:00

This solution also solves both network error and the service behind sql server

I answered a similar question here, you need to stat the other open Run type-> services.msc - under services -> sort by stopped you will see a bunch of stopped SQL services Right click and start

To begin - there are 4 issues that could be causing the common LocalDb SqlExpress Sql Server connectivity errors SQL Network Interfaces, error: 50 - Local Database Runtime error occurred, before you begin you need to rename the v11 or v12 to (localdb)\mssqllocaldb

I found that the simplest is to do the below - I have attached the pics and steps for help.

First verify which instance you have installed, you can do this by checking the registry and by running cmd

  1. cmd> Sqllocaldb.exe i
  2. cmd> Sqllocaldb.exe s "whicheverVersionYouWantFromListBefore" if this step fails, you can delete with option d cmd> Sqllocaldb.exe d "someDb"
  3. cmd> Sqllocaldb.exe c "createSomeNewDbIfyouWantDb"
  4. cmd> Sqllocaldb.exe start "createSomeNewDbIfyouWantDb"

SqlLOCALDb_edited.png

查看更多
骚的不知所云
3楼-- · 2018-12-31 01:00

This error occurs when your sql server instance is stopped.

GO to all Programs>SQL Server >Configuration tools>SQL SERVER CONFIGURATION MANAGER

then click on SQL sERVER SERVICES, list of instances will appear, select instance in question and click on play icon on top tool bar, hope this will help.

this answer is very late(but better late than never;)

查看更多
还给你的自由
4楼-- · 2018-12-31 01:01

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.

查看更多
荒废的爱情
5楼-- · 2018-12-31 01:04

If none of the above solutions work (nothing worked for me) then just RESTART your computer and you will be able to connect to your sql server (localhost).

查看更多
骚的不知所云
6楼-- · 2018-12-31 01:04

I am using SQL Server 2016 and Window 10.

enter image description here

First thing is to allow remote connection to SQL Server. What I did is to type sqlservermanager13.msc at start menu in order to open the SQL Server Configuration Manager. Make sure the TCP/IP status is enabled. enter image description here

Check your TCP port number by double click TCP/IP protocol name. Usually it is 1433 by default.

enter image description here

The following procedures configure the Windows Firewall by using the Windows Firewall with Advanced Security Microsoft Management Console (MMC) snap-in. The Windows Firewall with Advanced Security only configures the current profile.

To open a port in the Windows firewall for TCP access

  1. On the Start menu, click Run, type WF.msc, and then click OK.
  2. In the Windows Firewall with Advanced Security, in the left pane, right-click Inbound Rules, and then click New Rule in the action pane.
  3. In the Rule Type dialog box, select Port, and then click Next.
  4. In the Protocol and Ports dialog box, select TCP. Select Specific local ports, and then type the port number of the instance of the Database Engine, such as 1433 for the default instance. Click Next.
  5. In the Action dialog box, select Allow the connection, and then click Next.
  6. In the Profile dialog box, select any profiles that describe the computer connection environment when you want to connect to the Database Engine, and then click Next.
  7. In the Name dialog box, type a name and description for this rule, and then click Finish.

Another thing to configure.

To open access to SQL Server when using dynamic ports

  1. On the Start menu, click Run, type WF.msc, and then click OK.
  2. In the Windows Firewall with Advanced Security, in the left pane, right-click Inbound Rules, and then click New Rule in the action pane.
  3. In the Rule Type dialog box, select Program, and then click Next.
  4. In the Program dialog box, select This program path. Click Browse, and navigate to the instance of SQL Server that you want to access through the firewall, and then click Open. By default, SQL Server is at C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Binn\Sqlservr.exe. Click Next.
  5. In the Action dialog box, select Allow the connection, and then click Next.
  6. In the Profile dialog box, select any profiles that describe the computer connection environment when you want to connect to the Database Engine, and then click Next.
  7. In the Name dialog box, type a name and description for this rule, and then click Finish.

Have a look at Microsoft doucmentation Configure a Windows Firewall for Database Engine Access

查看更多
倾城一夜雪
7楼-- · 2018-12-31 01:04

I tried all the other answers on this question and some if not all probably played a part in getting this working for me, but I still couldn't connect to the DB remotely. I was using a SQL Server on an Azure VM.

I eventually remembered that the VM has endpoints that are controlled by the Azure account proxy, so I went on to the Azure Portal and added 1433 as an available endpoint and I could connect to my SQL instance.

Hope this helps someone who has tried all the other answers and is still having no luck!

查看更多
登录 后发表回答