IIS Express Debug Mode Issue
Asked Answered
K

6

7

There is an issue when I debugging my backend net5.0 project. The issue is "Web server failed to listen on port 5001" then I changed port but the problem does not change.

enter image description here

Kitten answered 26/8, 2022 at 12:27 Comment(10)
Port number could be blocked by a virus checker or another application is using the port.Epaulet
Have you checked if the port is currently in use? Try a netstat -ab to check.Aracelyaraceous
Might be a silly question and I don't know if your dev environment allows it, but have you set your DEV SSL port and HTTP port to the same port? i.e. 5001?Aracelyaraceous
@Tomás I checked but it is not in use.Kitten
{ "$schema": "http://json.schemastore.org/launchsettings.json", "profiles": { "Gateway.Command": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "swagger", "applicationUrl": "https://localhost:5001;http://localhost:5000", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Local" } } } } this is my launchSettings.jsonKitten
port can be used from antoher project when I debugged.Kitten
when I changed my port also getting same error. waiting for the web server to listen on port 53855 and then same result web server failed to listen on port 53855Kitten
I think issue is changed. Actually not changed. we identified the problem that is wrong with net5.0. I can debug my project with net3.1 and net6.0 but net5.0 is not working. I installed .net5.0 sdk and I used to VS Community 2022 then I changed to VS Enterprise 2022 maybe issue caused by this.Kitten
It's just waste of time to continue any investigation on .NET 5, as it reached end of life a while ago. VS2022 is known to stop supporting end-of-life technologies.Paschal
Try opening VS as administrator, I believe internal communication between .net architecture and IIS.Grosberg
B
4

I had the same issue after loading one of the existing project. I was able to resolve this by installing the .NET version project was targetting. (In my case, it was .NET 5).

Reason for the error: Since .NET's previous versions are out-of-support, Visual Studio won't install previous versions during installation.

Remedy: Intall SDK by yourself after installing Visual Studio

Belford answered 6/2, 2023 at 14:48 Comment(1)
Since Visual Studio 2019 updating it has become a nightmare, updates have failed every single time and it gives cryptic error messages which are hard to understand and fix. I uninstalled Visual Studio 2019(which supports .NET 5) and installed Visual Studio 2022(which doesn't support .NET 5) and tried to run a .NET 5 project and got this error "Process with an id of ### is not running" and then "Web server failed to listen on port". Why could it not give a simple understandable error saying, "The project is targeting .NET 5 which is unsupported. Try upgrading to .NET 6."? This is beyond me.Stylus
K
4

In my case that was

app.Run();

line deleted accidently from Program.cs

Killen answered 7/2, 2023 at 18:22 Comment(0)
D
3

For me the issue was that i added some configuration to the appsettings.json file and i forgot to add a comma. fixing that and everything was back to work.

Darin answered 24/6, 2023 at 13:51 Comment(3)
what is some configuration?Via
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Grearson
Goodness me, I wasted so much time on this. IntelliSense places a warning "Missing a comma after an object member" on the line in the appsettings.json file when you've got it open looking right at it but doesn't bother posting any warnings into the Error List tab where it would be easy to find.Urquhart
A
0

If you are using application url with port and you are using different url port in the environment variables settings in some field like origin. Then this problem arises. You have to keep them same.

Awildaawkward answered 26/8, 2022 at 12:33 Comment(1)
Actually I can debug another project. There is no problem. But this one does not work. It happens suddenly.Kitten
F
0

I had a similar Issue after updating my packages, to fix it:

Make sure that the DotNet version in the csproj is the same as the version found in the following folders:

C:\Program Files\dotnet\shared\Microsoft.NETCore.App C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App

So my csproj was contained:

<ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.4" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.4" PrivateAssets="all" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="7.0.4" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.4" />
  </ItemGroup>

So I made sure that all the File locations specified above the csproj file had versions 7.0.4.

Fazeli answered 21/3, 2023 at 20:15 Comment(0)
C
0

For me, this seemed to be caused by the random signing out of my Microsoft Account in Visual Studio 2022. As soon as I re-entered my creds, it went away.

Cobbie answered 9/2 at 1:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.