All attempts to expose a .NET 6 web API on port 8888 fail.
I tried these answers and various other articles online, by adding urls in appsettings.json and configuring the port in Program.cs without success.
Update: The web API starts on the default port and not on the port I want to expose it to. When configuring ports in Program.cs, I receive
System.InvalidOperationException: 'Changing the URL is not supported because Addresses IsReadOnly.'
app.Run("http://localhost:8888"); // This code results in Exception above
or
System.NotSupportedException: 'Collection was of a fixed size.'
app.Urls.Add("http://localhost:8888"); // The Exception above occurs after running this line of code
Running the code below doesn't change the port, and the API starts on the default port
builder.WebHost.ConfigureKestrel(options => options.ListenLocalhost(8888));