Can two Kestrel processes listen on different URLs in the same domain?

Viewed 999

Let's say I have two apps called "a"and "b". How can I get them to both run at the same time on the same domain under different virtual directories?

Identity should listen on http://localhost:8080/a/

var host = new WebHostBuilder()
    .UseKestrel()
    .UseContentRoot(Directory.GetCurrentDirectory())
    .UseIISIntegration()
    .UseUrls($"http://*:8080/a/")
    .UseStartup<Startup>()
    .Build();
host.Run();

Userprofiles should listen on http://localhost:8080/userprofiles/

var host = new WebHostBuilder()
    .UseKestrel()
    .UseContentRoot(Directory.GetCurrentDirectory())
    .UseIISIntegration()
    .UseUrls($"http://*:8080/b/")
    .UseStartup<Startup>()
    .Build();
host.Run();

The apps run individually but when I start them both at the same time I get this error

crit: Microsoft.AspNetCore.Server.Kestrel[0]
Unable to start Kestrel.
System.IO.IOException: Failed to bind to address http:/ /*:8080/userprofiles: address already in use. ---> System.AggregateException: One or more errors occurred. 
(Error -4091 EADDRINUSE address already in use) ---> Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvException: Error -4091 EADDRINUSE address already in use
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.ThrowError(Int32 statusCode)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.tcp_getsockname(UvTcpHandle handle, SockAddr& addr, Int32& namelen)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvTcpHandle.GetSockIPEndPoint()
1 Answers
Related