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.

Launch address already in use after initial launch of Blazor app

See original GitHub issue

Issue Description

Presented with error: “Address https://127.0.01:5001 address already in use” after initial launch of application. If I end the .Net Core Host process I experience the same issue presented here: #4056

This error doesn’t present itself if application is launched in Visual Studio as opposed to VSCode.

Steps to Reproduce

  1. Launch Blazor WebAssembly app
  2. Stop application
  3. Launch application again

Expected Behavior

Application launches without error to home page

Actual Behavior

Error message received: “The terminal process “cmd.exe ‘/c’, ‘chcp 65001 >NUL & dotnet run’” terminated with exit code: 3762504530”

Exception Log

Application: dotnet.exe CoreCLR Version: 4.700.20.47201 .NET Core Version: 3.1.9 Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.IOException: Failed to bind to address https://127.0.0.1:5001: 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.Bind() --- End of inner exception stack trace --- 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.KestrelServer.<>c__DisplayClass21_0`1.<<StartAsync>g__OnBind|0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- 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(IServerAddressesFeature addresses, KestrelServerOptions serverOptions, ILogger logger, Func`2 createBinding) at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken) at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken) at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken) at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token) at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token) at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host) at Microsoft.AspNetCore.Components.Web.DevServer.Commands.ServeCommand.Execute() at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args) at Microsoft.AspNetCore.Components.WebAssembly.DevServer.Program.Main(String[] args)

OmniSharp log

Starting OmniSharp server at 10/28/2020, 5:21:19 PM Target: c:\dev\BlazorTestProj

OmniSharp server started. Path: c:\Users\username.vscode\extensions\ms-dotnettools.csharp-1.23.4.omnisharp\1.37.3\OmniSharp.exe PID: 7304

    Starting OmniSharp on Windows 6.2.9200.0 (x64)
    DotNetPath set to dotnet
    Located 2 MSBuild instance(s)
        1: Visual Studio Professional 2017 15.9.28307.1000 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin"
        2: StandAlone 16.8.0 - "c:\Users\username\.vscode\extensions\ms-dotnettools.csharp-1.23.4\.omnisharp\1.37.3\.msbuild\Current\Bin"
    It looks like you have Visual Studio lower than VS 2019 16.3 installed.

Try updating Visual Studio to the most recent release to enable better MSBuild support. info: OmniSharp.MSBuild.Discovery.MSBuildLocator MSBUILD_EXE_PATH environment variable set to ‘c:\Users\username.vscode\extensions\ms-dotnettools.csharp-1.23.4.omnisharp\1.37.3.msbuild\Current\Bin\MSBuild.exe’ info: OmniSharp.MSBuild.Discovery.MSBuildLocator Registered MSBuild instance: StandAlone 16.8.0 - “c:\Users\username.vscode\extensions\ms-dotnettools.csharp-1.23.4.omnisharp\1.37.3.msbuild\Current\Bin” CscToolExe = csc.exe CscToolPath = c:\Users\username.vscode\extensions\ms-dotnettools.csharp-1.23.4.omnisharp\1.37.3.msbuild\Current\Bin\Roslyn MSBuildExtensionsPath = c:\Users\username.vscode\extensions\ms-dotnettools.csharp-1.23.4.omnisharp\1.37.3.msbuild MSBuildToolsPath = c:\Users\username.vscode\extensions\ms-dotnettools.csharp-1.23.4.omnisharp\1.37.3.msbuild\Current\Bin info: OmniSharp.Cake.CakeProjectSystem Detecting Cake files in ‘c:\dev\BlazorTestProj’. info: OmniSharp.Cake.CakeProjectSystem Could not find any Cake files info: OmniSharp.MSBuild.ProjectSystem No solution files found in ‘c:\dev\BlazorTestProj’ info: OmniSharp.MSBuild.ProjectManager Queue project update for ‘c:\dev\BlazorTestProj\BlazorTestProj.csproj’ info: OmniSharp.Script.ScriptProjectSystem Detecting CSX files in ‘c:\dev\BlazorTestProj’. info: OmniSharp.Script.ScriptProjectSystem Could not find any CSX files info: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0 info: OmniSharp.MSBuild.ProjectManager Loading project: c:\dev\BlazorTestProj\BlazorTestProj.csproj info: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0 info: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100 info: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110 info: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140 info: OmniSharp.WorkspaceInitializer Configuration finished. info: OmniSharp.Stdio.Host Omnisharp server running using Stdio at location ‘c:\dev\BlazorTestProj’ on host 15576. info: OmniSharp.MSBuild.ProjectManager Successfully loaded project file ‘c:\dev\BlazorTestProj\BlazorTestProj.csproj’. info: OmniSharp.MSBuild.ProjectManager Adding project ‘c:\dev\BlazorTestProj\BlazorTestProj.csproj’ info: OmniSharp.MSBuild.ProjectManager Update project: BlazorTestProj info: OmniSharp.OmniSharpWorkspace Miscellaneous file: c:\dev\BlazorTestProj\obj\Debug\netstandard2.1\Razor\App.razor.g.cs added to workspace info: OmniSharp.OmniSharpWorkspace Miscellaneous file: c:\dev\BlazorTestProj\obj\Debug\netstandard2.1\Razor\Pages\Index.razor.g.cs added to workspace info: OmniSharp.OmniSharpWorkspace Miscellaneous file: c:\dev\BlazorTestProj\obj\Debug\netstandard2.1\Razor\Pages\FetchData.razor.g.cs added to workspace info: OmniSharp.OmniSharpWorkspace Miscellaneous file: c:\dev\BlazorTestProj\obj\Debug\netstandard2.1\Razor\Pages\Counter.razor.g.cs added to workspace info: OmniSharp.OmniSharpWorkspace Miscellaneous file: c:\dev\BlazorTestProj\obj\Debug\netstandard2.1\Razor\Shared\NavMenu.razor.g.cs added to workspace info: OmniSharp.OmniSharpWorkspace Miscellaneous file: c:\dev\BlazorTestProj\obj\Debug\netstandard2.1\Razor\Shared\SurveyPrompt.razor.g.cs added to workspace info: OmniSharp.OmniSharpWorkspace Miscellaneous file: c:\dev\BlazorTestProj\obj\Debug\netstandard2.1\Razor_Imports.razor.g.cs added to workspace info: OmniSharp.OmniSharpWorkspace Miscellaneous file: c:\dev\BlazorTestProj\obj\Debug\netstandard2.1\Razor\Shared\MainLayout.razor.g.cs added to workspace

C# log

Post the output from Output-->C# here

Environment information

VSCode version: 1.50.1 C# Extension: 1.23.4

Dotnet Information .NET Core SDK (reflecting any global.json): Version: 3.1.201 Commit: b1768b4ae7

Runtime Environment: OS Name: Windows OS Version: 10.0.18363 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.1.201\

Host (useful for support): Version: 3.1.9 Commit: 774fc3d6a9

.NET Core SDKs installed: 2.1.508 [C:\Program Files\dotnet\sdk] 2.1.509 [C:\Program Files\dotnet\sdk] 2.1.511 [C:\Program Files\dotnet\sdk] 2.1.701 [C:\Program Files\dotnet\sdk] 2.1.801 [C:\Program Files\dotnet\sdk] 2.1.802 [C:\Program Files\dotnet\sdk] 2.2.401 [C:\Program Files\dotnet\sdk] 2.2.402 [C:\Program Files\dotnet\sdk] 3.0.100 [C:\Program Files\dotnet\sdk] 3.1.102 [C:\Program Files\dotnet\sdk] 3.1.201 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download

Visual Studio Code Extensions
Extension Author Version
csharp ms-dotnettools 1.23.4
debugger-for-chrome msjsdiag 4.12.11
remote-wsl ms-vscode-remote 0.50.1
vscode-icons vscode-icons-team 11.0.0
vscode-pull-request-github GitHub 0.20.1

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
captainsafiacommented, Apr 27, 2021

Yep – this particular issue is resolved.

1reaction
captainsafiacommented, Nov 2, 2020

Thanks for reporting this issue, @javsjmoore.

It looks like there was a regression in the code that terminates the application server when the user has stopped debugging. I can take a look at this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to bind to address (already in use) error with Visual ...
If you right click on your project, select options. Then Project Options Dialog will appear. On the left pane, goto Run->Configurations->Default ...
Read more >
Failed to bind to address address already in use (VS2019 Mac)
Io. Exception has been thrown. Failed to bind to address https://127.0.0.1:######: address already in use.”
Read more >
Port Already in Use Error Fix Don't Do This With Terminal
If you were using terminal or command prompt, closed it later on, ... 3000 is already in use and then you are unable...
Read more >
Blazor Tutorial | Build your first app - NET - Microsoft
Step-by-step instructions for building your first Blazor app. Develop with free tools for Linux, macOS, and Windows.
Read more >
Docker Error Bind: Address Already in Use
The Error “address already in use” occurred because some process was already running on the same port. So we can resolve the issue...
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