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
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.
---> Npgsql.NpgsqlException (0x80004005): Exception while connecting
---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (99): Cannot assign requested address [::1]:5451
If I connect the app to an external non-dockerized PostgreSQL - it works fine.
What is incorrect and how to fix it?
There is my docker-compose file
docker-composeordocker run? Please add the commands you use to run the containers5432instead of5451publish port using docker-compose network