ASP.net Core Web App not receiving requests when running in Docker container ASP.net Core Web App not receiving requests when running in Docker container docker docker

ASP.net Core Web App not receiving requests when running in Docker container


Your problem is caused by the way you specify the ASPNETCORE_URLS. Instead of binding to localhost, you should listen on all network interfaces in order to receive requests coming from outside the container.

This can be done by listening on 0.0.0.0 instead of localhost, or by using a wildcard, e.g.:

docker run -p 5000:5000 -e ASPNETCORE_URLS="http://+:5000"

In case of HTTP and HTTPS support:

docker run -p 5000:5000 -p 5001:5001 -e ASPNETCORE_URLS="http://+:5000;https://+:5001"

Or when using the default ports:

docker run -p 5000:80 -p 5001:443 -e ASPNETCORE_URLS="https://+;http://+"

My preferred approach is to use wildcard URLs and overwrite the port via an explicit environment variable when necessary, e.g.:

-p 5000:80 -p 5001:5001 -e ASPNETCORE_URLS="https://+;http://+" -e ASPNETCORE_HTTPS_PORT=5001