Reputation: 3056
When using Kestrel in an ASP.NET Core 2.1 project and specifying a binding in UseKestrel()
, a message is logged at warning level:
Overriding address(es) 'http://localhost:50000/'. Binding to endpoints defined in
UseKestrel()
instead.
This adds noise to our logs, reports a default (and therefore confusing) URL, and shouldn't be a warning. Short of filtering the message by the logger itself, is there a way to configure the web host builder so it doesn't log this on startup?
Upvotes: 37
Views: 38648
Reputation: 1630
This is an old question but you can resolve that conflict between launchSettings.json and appSettings.json with "externalUrlConfiguration": true
Kestrel configuration in appSettings.json:
"Kestrel": {
"EndpointDefaults": {
"Protocols": "Http1AndHttp2"
},
"Endpoints": {
"HTTPS": {
"Url": "https://localhost:4433"
}
}
And this is launchSettings.json content:
{
"profiles": {
"TestApplication": {
"commandName": "Project",
"launchBrowser": true,
"externalUrlConfiguration": true, //add this line
"applicationUrl": "https://localhost:5001",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Upvotes: 46
Reputation: 36
If can help someone, I was looking for something for my webapi in .NET 6 What solved for me was using the code below in launch.json
"env": {
"ASPNETCORE_URLS": "http://localhost:5050"
}
Upvotes: 1
Reputation: 99
None of the the previous answers worked for me. I defined my urls in builder.WebHost.UseKestrel(async options => )
I removed the following from appsettings.json and then the warning was gone.
"AllowedHosts": "*"
Upvotes: -1
Reputation: 1637
Had the same slightly annoying warning and checked the environment variables and configuration files, but was unable to locate the source of the url list. In the end I used IWebHostBuilder.UseUrls()
with an empty list of urls to get rid of the warning.
IWebHostBuilder builder = new WebHostBuilder()
.UseUrls()
.UseKestrel()
.ConfigureKestrel(...
Edit: For .net6
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseUrls();
Upvotes: 24
Reputation: 4566
It can also be a conflict between the configuration contained in launchsettings.json and appsetings.json
In my case, while developing locally, the Kestrel entry in appsetings.json:
"kestrel": {
"endpoints": {
"http": {
"url": "http://localhost:5000"
},
"https": {
"url": "https://localhost:5001"
}
}
was conflicting with a profile in the launchsettings.json:
"MyProject-Dev": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "http://localhost:5000;https://localhost:5001",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
I believe the right place for this is in the launchsettings.json file, so removing the kestrel entry in the appsettings.json solved my problem.
Upvotes: 11
Reputation: 388143
First of all, that “noise” is not really that noise if you consider that you only get this once when the application starts. So unless you are doing something weird where you need to restart your app, then you will probably almost never see that line in your logs, compared to all those other (much noisier) messages.
That being said, it is actually a useful warning because it tells you that you have configured the binding URL in multiple locations. So the proper action is not to ignore that message but to actually remove the duplicate configurations.
In this case, you are using explicit listen options with UseKestrel()
so that trumps everything. So you should remove the other configurations. There are a few locations where you should look:
ASPNETCORE_URLS
environment variable.ASPNETCORE_SERVER.URLS
environment variable.Properties/launchSettings.json
.Upvotes: 30