MS SQL Server exception on app startup

Hello,

I am getting a very strange exception when attempting to run my project from Visual Studio with the default development configuration.

Here’s a screenshot showing the exception:

And here are the exception details as plain text:

System.AggregateException
  HResult=0x80131500
  Message=One or more errors occurred. (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: 35 - An internal exception was caught))
  Source=System.Private.CoreLib
  StackTrace:
   at System.ThrowHelper.ThrowAggregateException(List`1 exceptions)
   at System.Threading.Tasks.Task.WaitAllCore(Task[] tasks, Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at Litium.Application.Runtime.ApplicationStartupEngine.Init()
   at Litium.Web.Runtime.Bootstrap.<>c__DisplayClass7_0.<Configure>b__0(IApplicationBuilder x)
   at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.<>c__DisplayClass0_0.<Configure>g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)
   at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.Hosting.GenericWebHostService.<StartAsync>d__37.MoveNext()
   at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>d__12.MoveNext()
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.<RunAsync>d__4.MoveNext()
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.<RunAsync>d__4.MoveNext()
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
   at Litium.Accelerator.Mvc.Program.Main(String[] args) in C:\Users\Dell\source\repos\PK-Produkter\Src\Litium.Accelerator.Mvc\Program.cs:line 22

  This exception was originally thrown at this call stack:
    [External Code]

Inner Exception 1:
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: TCP Provider, error: 35 - An internal exception was caught)

Inner Exception 2:
ExtendedSocketException: Name or service not known

This started happening after I updated Docker Desktop today, but it seems like the issue itself is not related to this since SQL Server is working as expected inside the container. It is in other words possible to connect to the database using SSMS as well as running queries.


The connection string that worked before and that I’m still using is this one:

"ConnectionString": "Pooling=true;User Id=sa;Password=Pass@word;Database=PKProdukter;Server=host.docker.internal,5434"

I also tried using 127.0.0.1,5434 instead of host.docker.internal,5434, but I ended up with the same exception.

Restarting Docker Desktop didn’t solve the issue, and neither did restarting the computer. I also tried cleaning the projects with dotnet clean, but unfortunately this did nothing.


A rather strange thing is that when I pinged host.docker.internal, I got the following IP:

image

Using this IP address in the connection string gave me even stranger results.

    "Data": {
      "ConnectionString": "Pooling=true;User Id=sa;Password=Pass@word;Database=PKProdukter;Server=192.168.0.16,5434"
    },

With the connection string above, the project runs without problems.


However, when I select a category or a product, I get the following exception page:


Has anyone had similar issues? If so, how did you solve it? I have tried a lot of things and I just can’t seem to get rid of the exception thrown by CreateHostBuilder. I even restored the local database to a version that works (our latest test environment DB), but even this was in vain.

Litium version: 8.5.0

Hi, it is probably because of the docker desktop upgrade. Your dns resolver is not working correctly. You have to reinstall your dnsresolver in docker by setting dns and DNSFORWARDER to 192.168.65.7 in your yaml file. See Shared dependencies.

I recommend to upgrade your Litium version to the latest one or at least 8.5.1 since 8.5.0 has memory leakage issue. See Release notes.

Setting the DNS forwarder to DNS_FORWARDER=192.168.65.7 and dns: 192.168.65.7 indeed solved the issue. Thank you for your help! :+1:

Edit: We are planning on updating our Litium version to 8.5.1 as soon as possible, maybe even by the end of this week.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.