Last post Oct 13, 2017 04:32 PM by rrkreitler
Oct 12, 2017 07:33 PM|rrkreitler|LINK
When my ASP app tries to access the SQL instance it fails with:
"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: 50 - Local Database Runtime error occurred. The specified LocalDB instance does not exist. )"
If I run the app in debug mode from VS it runs fine. This error only occurs when I open my browser and run the app via localhost through IIS. Incidentally, the app runs fine from localhost up to the point it tries to access the SQL instance.
I have a dev machine running Windows 10 Pro (1703), VS 2017 Community 15.3.5, SQL 2016 (LocalDB), and IIS (from Windows 10).
I am building an ASP (.NET 4.6.1) project that uses EF 6.1.3.
What I have done so far
Before I go too far down the rabbit hole I will say I have tried MANY different permutations of configurations in IIS involving combinations of the IIS APPPOOL\App account and IIS_IUSRS as well as making sure the accounts have access to the database location
(via folder security settings) and the database itself (via SSMS).
I have tried enabling auditing on my SQL to monitor logon failures and it is not recording any logon attempts so I am having trouble getting the system to tell me the actual account context that is failing.
Can anyone shed any light on this? It has crossed my mind to wonder if this is because I am using LocalDB so SQL is not running as a service (thus no service accounts involved) and there is some assumption somewhere about the default application pool identity
being a service account.
Before I go to the length of moving up to SQL Express to test the service account angle, I want to ask if anyone has any other suggestions for the existing configuration.
Oct 13, 2017 06:53 AM|Deepak Panchal|LINK
many of the ports and services are refrained from running by
firewall. Time and again, SQL Server ports are not open in firewall as well.
All the ports on which SQL Server is running should be added to
exception and firewall should filter all the traffic from those ports.
As described, by default SQL Server runs on port 1433, but if
default port is changed then the new port should be added to
check that "Allow remote connection to this server" option is checked.
other reference that may help you.
Why am I getting “Cannot Connect to Server - A network-related or instance-specific error”?
Oct 13, 2017 04:32 PM|rrkreitler|LINK
Thank you for the response. I have verified the port and firewall settings and everything is configured properly.
I believe this problem is related specifically to some issue between IIS and using LocalDb.
After all the tests I have done, it appears that the connection is being made in the context of my user account (makes sense since I am using SQL LocalDB) rather than a service account, however it appears that SQL is trying to authorize the connection
based on the AppPool ID rather than the account actually making the request.
I came to this conclusion because the only time the app successfully connected to the localdb via IIS was when I changed application pool ID to be my own user account.
This morning I decided to install an instance of SQLEXPRESS. I configured the app to point to the SQLEXPRESS instance, granted SQL permission to application pool ID and everything immediately worked.
At this point I am not certain if the problem with LocalDb is on the SQL or the IIS side of the equation.
I need to get on with the project so I am not going to spend any more time on this. I am posting my experience here in case anyone else runs into this. If anyone has any more insight into this I am still interested.