Issue
I am having issues with a SQL Server connection string that is being used by a .net core App that is deployed on a Linux environment. The .net core app needs to access a sql server on a different server.
My connection string I am using is as follows
"ConnectionStrings" : {
SQLDbContext": "Server=serverabc\\dev_xys;Database=mynewDatabase;Integrated Security = True"
}
It works fine when i run locally on my windows pc
But when its deployed to the Linux box i get the following error
ExtendedSocketException: Name or service not known
System.Net.Dns.GetHostEntryOrAddressesCore(string hostName, bool justAddresses) in Dns.cs, line 323
Exception: Cannot connect to SQL Server Browser. Ensure SQL Server Browser has been started
I have checked the Service account that runs the .Net Service Deployed has access to the database.
Does the connection string need altering?
Solution
This will only work if
- SQL Server has TCP/IP enabled, and the Browser Service running
- The Windows firewall allows UDP port 1434 and TCP on whatever port the SQL Server instance is listening on.
- The client can resolve the hostname
Or you could use the SQL Server Configuration Manager to set the SQL Server instance to listen on a fixed port (1433 is the default), and specify that instead of the instance name in your connection string.
Answered By - David Browne - Microsoft