question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

Describe 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:closed
  • Created 3 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
halter73commented, Mar 2, 2021

Thanks @lluchmk!

1reaction
Tratchercommented, Feb 5, 2021

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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to bind to http://localhost:5000 on the IPv6 ...
The original issue is caused by an attempt to bind to localhost which AFAIK is not allowed from inside a docker container. But...
Read more >
Run .Net core application inside a docker
Unable to bind to http:localhost:5000 on the IPv6 loopback interface: 'Cannot assign requested address'. docker ps output
Read more >
Why isn't my ASP.NET Core app in Docker working?
Kestrel[0] Unable to bind to http://localhost:5000 on the IPv6 loopback interface: 'Cannot assign requested address'. dbug: Microsoft.
Read more >
Docker – Unable to bind to http://localhost:5000 on the IPv6 ...
Unable to bind to http://localhost:5000 on the IPv6 loopback interface: 'Cannot assign requested address'. Loaded '/usr/share/dotnet/shared/Microsoft.
Read more >
Unable to bind to http://localhost:5000 on the IPv6 loopback ...
Coding example for the question Unable to bind to http://localhost:5000 on the IPv6 loopback interface: 'Cannot assign requested address'-docker.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found