Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blazor WebAssembly: Port 9300 already in use #25887

Closed
danroth27 opened this issue Sep 14, 2020 · 6 comments
Closed

Blazor WebAssembly: Port 9300 already in use #25887

danroth27 opened this issue Sep 14, 2020 · 6 comments
Labels
area-blazor Includes: Blazor, Razor Components

Comments

@danroth27
Copy link
Member

Reported by @helios2052 dotnet/core#5200 (comment)

I noticed that in both my upgraded app and in the sample RC1 blazor-wasm hosted template (w/auth), it will startup and run ok the first time, but throws an exception on the next and subsequent startups w/debugging.

It seems like possibly this error only happens if you stop the app/browser by pressing "stop debugging" in visual studio and then re-launch. If you close the browser directly, visual studio then stops debugging as usual and you can restart the app with no issues. I have to go into task manager and clear out any stuck ".NET HOST" processes and then relaunch each time.

error

Unhandled exception. System.IO.IOException: Failed to bind to address http://127.0.0.1:9300: address already in use.
 ---> Microsoft.AspNetCore.Connections.AddressInUseException: Only one usage of each socket address (protocol/network address/port) is normally permitted.
 ---> System.Net.Sockets.SocketException (10048): Only one usage of each socket address (protocol/network address/port) is normally permitted.
   at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)
   at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Bind(EndPoint localEP)
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.g__BindSocket|13_0(<>c__DisplayClass13_0& )
   --- End of inner exception stack trace ---
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.g__BindSocket|13_0(<>c__DisplayClass13_0& )
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.Bind()
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportFactory.BindAsync(EndPoint endpoint, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.TransportManager.BindAsync(EndPoint endPoint, ConnectionDelegate connectionDelegate, EndpointConfig endpointConfig)
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.<>c__DisplayClass29_0`1.<g__OnBind|0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindEndpointAsync(ListenOptions endpoint, AddressBindContext context)
   --- End of inner exception stack trace ---
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindEndpointAsync(ListenOptions endpoint, AddressBindContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.LocalhostListenOptions.BindAsync(AddressBindContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IEnumerable`1 listenOptions, AddressBindContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Hosting.WebHost.StartAsync(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String startupMessage)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String startupMessage)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
   at Microsoft.WebAssembly.Diagnostics.Program.Main(String[] args)

fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
      An unhandled exception has occurred while executing the request.
      System.InvalidOperationException: No output has been recevied from the application.
         at Microsoft.AspNetCore.Builder.DebugProxyLauncher.LaunchAndGetUrl(IServiceProvider serviceProvider, String devToolsHost)
         at Microsoft.AspNetCore.Builder.WebAssemblyNetDebugProxyAppBuilderExtensions.<>c.<b__0_1>d.MoveNext()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
         at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.MigrationsEndPointMiddleware.Invoke(HttpContext context)
         at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)
         at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)
         at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
@pranavkm pranavkm added the area-blazor Includes: Blazor, Razor Components label Sep 14, 2020
@Pilchie
Copy link
Member

Pilchie commented Sep 14, 2020

Pretty sure we recently fixed this? @mkArtakMSFT or @lewing @captainsafia ?

@captainsafia
Copy link
Member

Yep, we did. Unfortunately, it didn't make the cut-off for RC1 so we shipped it with RC2.

I've responded to the user here.

@rbhanda rbhanda mentioned this issue Sep 14, 2020
4 tasks
@mkArtakMSFT
Copy link
Member

Closing this as this is now fixed in RC2.

@ghost
Copy link

ghost commented Sep 16, 2020

I got bit by this today after upgrading a project. How soon until RC2 is released?
Also, are there any good workarounds? I've killed the ".NET HOST" process but that results in the following error on my next debug launch:
image

@tossnet
Copy link

tossnet commented Sep 16, 2020

ok but this solution to clear out any process ".NET Host" only works once. Then, if we modify our code, this process is no longer in the tasks manager and the error come back

@Postlagerkarte
Copy link

This works for me while waiting for the fix:

npm install --global kill-port

and add to your .csproj

<PropertyGroup>
    <DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
</PropertyGroup> 
<PropertyGroup>
    <PreBuildEvent>kill-port 9300</PreBuildEvent>
</PropertyGroup>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

No branches or pull requests

7 participants