title: How to connect Dockerized ASP.NET Core app ->Dockerized PostgreSQL?
body: <p>I have 2 Dockers:
  my ASP.NET Core Web server   -p 5001:80
  postgresql -p 5451:5432
  When I configure my Web Server to work with postgresql running on my host it works.
  But when I run  configure myWeb App to work with postgresql in Docker , run  http://localhost:5001 it</p>
  <pre><code>starts but then an error appears:
  
      warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3]
            Failed to determine the https port for redirect.
      fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
            An unhandled exception has occurred while executing the request.
      System.InvalidOperationException: An exception has been raised that is likely due to a transient failure.
       ---&gt; Npgsql.NpgsqlException (0x80004005): Exception while connecting
       ---&gt; System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (99): Cannot assign requested address [::1]:5451
  </code></pre>
  <p>If I connect the app to an external non-dockerized PostgreSQL - it works fine.</p>
  <p>What is incorrect  and how to fix it?</p>
  <p>There is my docker-compose file</p>
  <p><a href="https://pastebin.com/b8FbHSLL" rel="nofollow noreferrer">https://pastebin.com/b8FbHSLL</a></p>