6
  1. When I run my ASP.NET Core (Blazor Server) app using Visual Studio, it listens on port 5003,
  2. when using dotnet watch --project app\App.csproj run, it listens on different port - 5001!

Here is my launchSettings.json

"App": {
  "commandName": "Project",
  "dotnetRunMessages": "true",
  "launchBrowser": true,
  "applicationUrl": "https://localhost:5003;http://localhost:5002",
  "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Development",
    "LocalUrl": "https://localhost:5003"
  }
}

Why the dotnet run starts on different port and how to make it to run on 5003?


Addional info:

The app was created in .NET 5 and the problem occured after upgraded the SDK and PackageReferences .NET 6,

Liero
  • 25,216
  • 29
  • 151
  • 297
  • It looks like it doesn't take your `launchSettings.json` into account. It could be a regression, but I'm not sure. You can make it work with something like this: `dotnet watch --project app\App.csproj run --launch-profile App`, but that's less than ideal, I know. – Kirk Larkin Nov 11 '21 at 18:07
  • 1
    I am also having this issue on a project that came originally from .net 2.2, straight up to .net 6. Did you find any resolution? New projects on .net6 don't have the issue. It is odd that it is using port 5001, as .net 6 should create a random port - there must be something lingering from the old project. – Adam Marshall Dec 06 '21 at 22:10

1 Answers1

4

It's a known bug in .NET 6, see:

Liero
  • 25,216
  • 29
  • 151
  • 297