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 00:50

It seems that your instance of localdb is not running. To start it on computer startup, add into your Start menu \ Startup folder BAT file with following line

sqllocaldb start name_of_instance

where name_of_instance is name of localdb instance, which you want to start. You can list available instances in command line using sqllocaldb i.

e.g. If you're using SQL Server Management Studio and connecting to Server Name (localdb)\v11.0, then your BAT file will look like

sqllocaldb start v11.0
查看更多
唯独是你
3楼-- · 2018-12-31 00:51

I am solving that problem by opening Services then start running Sql Server (Sqlexpress) service.

service Image

查看更多
心情的温度
4楼-- · 2018-12-31 00:52

I have to run SQL Server Browser service into SQL Server Configuration Manager. Installation can't discover newly created service without this.

查看更多
刘海飞了
5楼-- · 2018-12-31 00:52

I moved from a work laptop on Windows 7 to a work laptop on Windows 10. I had been successfully using SSMS2016 on Windows 7.

The same issue applied using SSMS2012 or SSMS2016. My access to the 10 sql servers using windows authentication was still the same. I could test this from another server. However, 2 of the 10 servers would not connect from my laptop. Both were ms sql server 9 but I could connect to other sql server 9 databases.

The solution was to add a firewall rule (using Windows Firewall with Advanced Security).

Create an Incoming rule for each SSMS eg C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\ManagementStudio\Ssms.exe

I'm not a network expert so I've not included the details but hopefully it will point you in the right direction.


Error msg (pre firewall rule) "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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (.Net SqlClient Data Provider)"

查看更多
无与为乐者.
6楼-- · 2018-12-31 00:55

Along with trying everything as suggested by Teo Chuen Wei Bryan, make sure you are also referring to the correct Server/Instance name in the connection string.

If you are using the short form of host name/Instance on the database server or in the web.config file, make sure you use the fully qualified domain name(FQDN)/Instance

Also, to test connectivity from a server where SQL server client is NOT present,

--> create a text file and change its file extension to .udl

--> Right click the file and you can see connection tab.

--> Input server name and log on information to test connection to the database server.

Hope this helps.

查看更多
无与为乐者.
7楼-- · 2018-12-31 00:58

After doing everything mentioned here:
http://blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error/ Still did not work for me.

Steps worked for me:

Start > Run > cmd > sqlcmd -L

It will prompt you the server name. Make sure this server name is same as the one you are trying to get connected to in CONNECT TO SERVER box of SQL management studio.

I made this silly mistake I keep using MSSQLSERVER rather using this server name.

Hope this helps for the people who make silly mistake like me.

Thanks.

查看更多
登录 后发表回答