Why I am not able to connect to remote SQL Server

2019-08-09 04:58发布

Why I am not able to connect to remote server from asp.net website whereas it is connecting from SSMS

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)

I tried all the possible solution suggested in this link

I checked Followings as given in the above article, they are enabled/running

  1. SQL Server is up and running.
  2. TCP/IP enabled in SSCM
  3. Opened port in Windows Firewall
  4. Remote Connection enabled
  5. SQL Server Browser Service running

I searched for sqlbrowser.exe but it is not found in the given directory.

Finally I switched off Windows Firewall but still it is not working.

UPDATE: we are connecting to sql server using a custom user created on sql server (not sa ) I have user account credential to Remote connect to server. I tried to change LogOn to my credentials (administrator) . in Windows Services SQL Server (MSSQlServer) and SQL Server Agent (MSSQL Server) services.

4条回答
我只想做你的唯一
2楼-- · 2019-08-09 05:35

Double check your connection string - are you connecting to a hostname that needs to be added to your Hosts file? For example "dev-sql1" but without a matching entry in dns or hosts file.

查看更多
放我归山
3楼-- · 2019-08-09 05:37

I got the same issue but with mysql server. Rack space had two mysql server address. One for connecting from outside their local network and one for connecting from inside the network. you will have to use the address that is required to connect from inside the network.

查看更多
We Are One
4楼-- · 2019-08-09 05:39

If you have created a custom user, can you check if logins are disabled for the user? In SSMS, goto Security, right click user, Properties -> Status, Login - Enabled.

Hope this should fix it.

查看更多
Explosion°爆炸
5楼-- · 2019-08-09 05:44

Three possibilities and they are not mutually exclusive.

  1. Most hosting providers disable remote connections to SQL servers. Check with RackSpace if blocking port 1433

  2. The SQL Server needs to be reconfigured to accept remote connections. See http://support.microsoft.com/kb/914277

  3. You have to use a different connection string. See http://www.connectionstrings.com/sql-server and look for Connect via an IP address

查看更多
登录 后发表回答