Unable to bind to http://localhost:5000 on the IPv6 loopback interface: 'Cannot assign requested address'
See original GitHub issueDescribe the bug
My ASP.NET Core 5 application works fine locally in Mac/Windows when debugging through VS Code, Rider or VS. But when when trying to spin up a container from the image, it will always give the following warning and the application would not respond to any request.
warn: Microsoft.AspNetCore.Server.Kestrel[0]
Unable to bind to http://localhost:5000 on the IPv6 loopback interface: 'Cannot assign requested address'.
To Reproduce
Create any ASP.NET Core 5 application and add the following line in Startup.cs
.ConfigureServices(IServiceCollection services)
method.
services.AddSingleton(sp => Configuration);
Someone else asked the question before as well: https://stackoverflow.com/q/65836031/1565402
Exceptions (if any)
none
Further technical details
.NET SDK (reflecting any global.json): Version: 5.0.102 Commit: 71365b4d42
Runtime Environment: OS Name: Mac OS X OS Version: 11.0 OS Platform: Darwin RID: osx.11.0-x64 Base Path: /usr/local/share/dotnet/sdk/5.0.102/
Host (useful for support): Version: 5.0.2 Commit: cb5f173b96
VS 2019, VS Code, Rider
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (7 by maintainers)
Thanks @lluchmk!
Binding to localhost binds to two separate addresses,
127.0.0.1
(IPv4) and::1
(IPv6). Some environments like containers will not support one, but still successfully start on the other. That’s why this is a warning and not an error.@halter73 should this be downgraded to Info, and only produce an error if both fail?