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.

AspNetCore RC2: Kestrel server won't bind to multiple server.urls

See original GitHub issue

The server is not honoring server url bindings when launching web apps using .Net Core RC2 VS tools, eg this doesn’t work:

var host = new WebHostBuilder()
    .UseKestrel()
    .UseContentRoot(Directory.GetCurrentDirectory())
    .UseUrls("http://localhost:60000", "http://localhost:60002")
    .UseIISIntegration()
    .UseStartup<Startup>()
    .Build();

host.Run();

However, everything works fine when launching this way:

project-root > dotnet run

I’ve been digging around, and can’t find much on this topic other than a few related issues:

I tried moving the urls to a server.urls variable in an external hosting.json file and using the configuration builder as suggested in the 2nd link, but that’s not working either.

var config = new ConfigurationBuilder()
    .SetBasePath(Directory.GetCurrentDirectory())
    .AddJsonFile("hosting.json", optional: true)
    .Build();

var host = new WebHostBuilder()
    .UseKestrel()
    .UseConfiguration(config)
    .UseContentRoot(Directory.GetCurrentDirectory())         
    .UseIISIntegration()
    .UseStartup<Startup>()
    .Build();

host.Run();

//  contents of hosting.json, 
// {
//   "server.urls": "http://localhost:60000 http://localhost:60002"
// }

The hosting.json file is located in the project root along side project.json and was created based on the only example I could find:

Although seemlingly promising, that didn’t work either.Are you having this issue too or has anyone else reported it?

I’m using 1.0.0-preview1-002702.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ariesdanecommented, May 31, 2016

I’m going to close this issue. It’s not related to SaasKit, and it’s easy enough to fix by doing the following:

  1. Open the solution’s \.vs\config\applicationhost.config file
  2. Manually add the additional entries to the site’s <bindings></bindings>

Before

<bindings>
   <binding protocol="http" bindingInformation="*:60000:localhost" />
</bindings>

After

<bindings>
   <binding protocol="http" bindingInformation="*:60000:localhost" />
   <binding protocol="http" bindingInformation="*:60001:localhost" />
   <binding protocol="http" bindingInformation="*:60002:localhost" />
   <binding protocol="http" bindingInformation="*:60003:localhost" />
   <binding protocol="http" bindingInformation="*:60004:localhost" />
</bindings>
0reactions
rondefreitascommented, Jun 3, 2016

It’s an issue with IIS Express, and yes, changing ApplicationHost.config is the way to resolve it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Kestrel :: Bind to multiple HTTP and HTTPS urls through ...
I have a ASP.NET Core service build in .Net 5 which uses Kestrel as edge server. The service needs to listen on multiple...
Read more >
How to configure urls for Kestrel, WebListener and IIS ...
In this post I describe how to configure the URLs your application binds to when using Kestrel or the WebListener HTTP servers.
Read more >
Configure endpoints for the ASP.NET Core Kestrel web ...
If no ports are specified, Kestrel binds to http://localhost:5000 . Specify URLs using the: ASPNETCORE_URLS environment variable. --urls command ...
Read more >
How to configure Kestrel URLs in ASP.NET Core RC2
NET Core RC2 Kestrel would be configured as part of the command bindings in project.json : "commands": { "web": "Microsoft.AspNet.Server.
Read more >
Kestrel web server in ASP.NET Core
Kestrel used as an edge server without a reverse proxy server doesn't support sharing the same IP and port among multiple processes.
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