Docker: dotnet core - Cannot assign requested address'

Date: 2020-11-26 | docker | dotnet-core | port |

Overview

I'm running a dotnet core dockerized app and trying to change its default port to http://localhost:8080 via the appsettings.json Urls field. However, I keep getting this error when running the container:

Unable to bind to http://localhost:8080 on the IPv6 loopback interface: 'Cannot assign requested address'.

How can I fix this?

Solution

The solution seems to be to change localhost to host.docker.internal. I don't really know why this is but that worked for me.

Want more like this?

The best / easiest way to support my work is by subscribing for future updates and sharing with your network.