Failed to bind to address (already in use) error with Visual Studio Mac API

后端 未结 7 1765
隐瞒了意图╮
隐瞒了意图╮ 2021-01-21 03:34

I\'m attempting to create a Web API via .Net Core. I\'m just using the boilerplate ValuesController as a Hello World. When I run the project, I get the following error:

7条回答
  •  孤街浪徒
    2021-01-21 04:09

    The port 5001 has already used in your system. Change port number to 5002 or whatever you want.

    You can add port number with .UseUrls into CreateWebHostBuilder

      public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseUrls("http://localhost:5002")
                .UseStartup();
    

    Or if you use visual studio code, just replace args section in .vscode -> launch.json.

    "args": ["urls=http://localhost:5002"]
    

提交回复
热议问题