# MS SQL Server exception on app startup

**URL:** <https://forum.litium.com/t/ms-sql-server-exception-on-app-startup/2835>\
**Category:** Questions\
**Tags:** litium-8\
**Created:** [February 1, 2023, 7:09pm UTC](https://forum.litium.com/t/ms-sql-server-exception-on-app-startup/2835 "2023-02-01T19:09:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DimObr](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/dimobr/32/796_2.png) [@DimObr](https://forum.litium.com/u/DimObr)\
**Post date:** [February 1, 2023, 7:09pm UTC](https://forum.litium.com/t/ms-sql-server-exception-on-app-startup/2835/1 "2023-02-01T19:09:25Z")

</div>

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:

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/036e125f29f1784bb67d91a5114da15af1b5cec1.png)

And here are the exception details as plain text:

```plaintext
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:

```plaintext
"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](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/4125990023dadc29dd4b731bd0e91e762657b39a.png)

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

```json
    "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.

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/248a55f1d162e85abd75c97d99ec98f243ae1956.png)

  

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

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/6f4880540aa60a4971db2aa9711aa94be8720d1f.png)

  

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

---

<div class="post-metadata">

**Author:** ![utku](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/utku/32/62_2.png) [@utku](https://forum.litium.com/u/utku)\
**Post date:** [February 2, 2023, 7:29am UTC](https://forum.litium.com/t/ms-sql-server-exception-on-app-startup/2835/2 "2023-02-02T07:29:42Z")

</div>

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](https://docs.litium.com/platform/get-started/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](https://docs.litium.com/platform/release-notes).

---

<div class="post-metadata">

**Author:** ![DimObr](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/dimobr/32/796_2.png) [@DimObr](https://forum.litium.com/u/DimObr)\
**Post date:** [February 2, 2023, 8:31am UTC](https://forum.litium.com/t/ms-sql-server-exception-on-app-startup/2835/3 "2023-02-02T08:31:18Z")

</div>

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! 👍

**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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/12eddac3b8b661de1db86af10ac8151b571e6fb9.png) [@system](https://forum.litium.com/u/system)\
**Post date:** [March 2, 2023, 8:31am UTC](https://forum.litium.com/t/ms-sql-server-exception-on-app-startup/2835/4 "2023-03-02T08:31:33Z")

</div>

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