HTTP Error 400 - invalid hostname
The AllowedHosts setting of your application does not match your domain.
The page shows Bad Request – Invalid Hostname (HTTP Error 400), typically right after you connected your own domain to an ASP.NET Core application.
This message comes from your application. ASP.NET Core checks the host name of every request against the AllowedHosts setting, and rejects requests for a domain that is not on the list.
Fix the AllowedHosts setting
Open appsettings.json of your application and find AllowedHosts. Either allow every host name:
{
"AllowedHosts": "*"
}
or list all addresses of your website, separated by semicolons:
{
"AllowedHosts": "example.com;www.example.com;mysite.runasp.net"
}
Upload the changed file (or publish the application again). The application restarts by itself when appsettings.json changes.
Note
Remember to include every address visitors use: the domain with and without www, and the original runasp.net address if you still want it to work.
Still the same error?
Check that the domain is added to the website in the Control Panel under Domains. A domain that points to our servers but is not added to any website shows our generic hosting page instead of your application. See Add your own domain to a website.