title: Asp.net core in docker Unhandled exception. SqlException (0x80131904): .., but then an error occurred during the pre-login handshake
body: <p>I'm getting the error</p>
  <p>&quot;Unhandled exception. Microsoft.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - Unknown error 203)&quot;</p>
  <p>when I start asp.net core application container using docker-compose in CI/CD flow from gitlab (self-hosted) runner on ubuntu 19.10 all docker images - latest.</p>
  <p>After MSSQL starting i can normally connect to it using SSMS but application fails with the exception.</p>
  <p>TargetFramework: netcoreapp3.1
  ORM: EntityFrameworkCore 3.1.4</p>
  <p>docker-compose.yml</p>
  <pre><code>version: '3.4'
  
  services:
    websiteanalyzer:
      container_name: project-aspnet-core
      image: registry.gitlab.example.com/user/project/imagename:develop
      ports:
        - &quot;34080:34080&quot;
      volumes:
        - /data/project/app/conf/appsettings.json:/app/appsettings.json
      depends_on:
        - db
    db:
      container_name: project-db
      image: &quot;mcr.microsoft.com/mssql/server&quot;
      environment:
          SA_PASSWORD: &quot;password&quot;
          ACCEPT_EULA: &quot;Y&quot;
      ports:
        - &quot;34433:1433&quot;
      volumes:
        - /data/project/mssql/data:/var/opt/mssql/data
        - /data/project/mssql/log:/var/opt/mssql/log
        - /data/project/mssql/secrets:/var/opt/mssql/secrets
  </code></pre>
  <p>Dockerfile</p>
  <pre><code>FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
  WORKDIR /app
  EXPOSE 80
  #EXPOSE 443
  
  FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
  #WORKDIR /src
  #COPY [&quot;src/Project/Project.csproj&quot;, &quot;Project/&quot;]
  #RUN dotnet restore &quot;Project/Project.csproj&quot;
  COPY . .
  RUN dotnet restore &quot;src/Project/Project.csproj&quot;
  #WORKDIR &quot;/src/Project&quot;
  RUN dotnet build &quot;src/Project/Project.csproj&quot; -c Release -o /app/build
  
  FROM build AS publish
  RUN dotnet publish &quot;src/Project/Project.csproj&quot; -c Release -o /app/publish
  
  FROM base AS final
  WORKDIR /app
  COPY --from=publish /app/publish .
  ENTRYPOINT [&quot;dotnet&quot;, &quot;Project.dll&quot;]
  </code></pre>
  <p>appsettings.json</p>
  <pre><code>{
    &quot;ConnectionStrings&quot;: {
      &quot;DefaultConnection&quot;: &quot;Server=db,34433;Database=master;User Id=sa;Password=password;MultipleActiveResultSets=true&quot;
    },
    &quot;Logging&quot;: {
      &quot;LogLevel&quot;: {
        &quot;Default&quot;: &quot;Information&quot;,
        &quot;Microsoft&quot;: &quot;Warning&quot;,
        &quot;Microsoft.Hosting.Lifetime&quot;: &quot;Information&quot;
      }
    },
    &quot;AllowedHosts&quot;: &quot;*&quot;
  }
  </code></pre>
  <p>Any idea what might have gone wrong here?</p>