Error connecting to MS SQL from one server but not the other
Our hosting company had restricted the connection to SQL server to only be from IP addresses from the local network. The old website server was within this local network but the new website was in a different network. Our hosting company ended up fixing the issue after going several rounds them.
What threw me off was that when I remotely logged in on the new web server, then I could both ping and access the server by telnet using the port that MS SQL uses. I installed Management Studio on the web server and I was not able to connect to the MS SQL server using it. Somehow the restriction managed to differ what kind of connection it was and restricted it only to not allow SQL connections.
This was quite specific case but hope what people can take from it is how to debug and determine where the issue lays.
Related videos on Youtube
Arne H. Bitubekk
.Net Developer with love for web development
Updated on September 18, 2022Comments
-
Arne H. Bitubekk over 1 year
We got a MS SQL server and two web site servers. I'm in the process of moving all the sites from one of the web site servers to the new one.
My asp.net sites are not able to connect to the external ms sql server after I've moved them to the new server. I'm able to both ping the MS SQL server and access it by telnet using the port 1433 from the web site server.
It works perfect from the old web site server so my guess is that there's something to do with the new server. I've tried to disable the firewall without it helping either.
Help would be much appreciated!
I get the following errors on two different sites (one running .net 2 and other .net 4):
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)
Exception Details: System.Data.SqlClient.SqlException: 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)
[SqlException (0x80131904): 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)]
DataAccessManager.ExecuteNonQuery(DbCommand command) in C:\Websites*\App_Code\DataAccessManager.vb:31
InsiteError.Save() in C:\Websites*\App_Code\System\InsiteError.vb:89And
The network path was not found
Exception Details: System.ComponentModel.Win32Exception: The network path was not found
[Win32Exception (0x80004005): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond]
[SqlException (0x80131904): 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: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)]
DataAccessManager.ExecuteSelectCommand(DbCommand command) in C:\Websites*\App_Code\DataAccessManager.vb:18
InsitePage..ctor(String file_name, PageResult& Result) in C:\Websites*\App_Code\InsitePage\InsitePage.vb:68
_Default.Page_PreInit(Object sender, EventArgs e) in C:\Websites*\default.aspx.vb:298
BasePage.OnPreInit(EventArgs e) in C:\Websites*\App_Code\System\BasePages\BasePage.vb:249 System.Web.UI.Page.PerformPreInit() +49
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1844-- Update -- Trying to connect with ms sql management studio from the new server do I get the following error:
TITLE: Connect to Server
Cannot connect to *.
------------------------------ ADDITIONAL INFORMATION:
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: 53)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=53&LinkId=20476
The network path was not found
-
jimtut about 10 yearsCan you install Mgmt Studio on the new server and use that to connect to the DB? I find it easier to debug connection issues there, rather than inside the app under IIS.
-
Arne H. Bitubekk about 10 years@KatherineVillyard Yup, on the new server and yeah same ip and port :)
-
Arne H. Bitubekk about 10 years@jimtut Good idea, I'll test that now :)
-
Katherine Villyard about 10 yearsAre both SQL instances "default" instances, or named instances?
-
Travis J over 9 yearsDid you ever resolve this issue?
-
Arne H. Bitubekk over 9 yearsIt was some network and firewall related issues. The connection between the two servers had to be done with the local IP between them and not the external one. Those that was hosting the servers failed to give any information about this so took me a while to figure it out.
-
Doug McLean over 7 yearsI realise the last activity on this was 2 years ago but @ArneHB I'd recommend adding an answer, since you found a solution. It may well help others in future. It's fine to answer your own question.
-