The following code just won't change the port to 9874. It stays the same in Project -> Debug -> Web Server Settings -> App URL -> "<http://localhost:56021/>", which uses the 56021 port. I am using VS 2017 to create .net core webapi project.

```
public static IWebHost BuildWebHost(string[] args) =>
    WebHost.CreateDefaultBuilder(args)
        .UseStartup<Startup>()
        .UseUrls("http://localhost:9874")
        .Build();

```

It is the same even i change to Release mode.