Search code examples
asp.netlocalhostiis-express

Invalid Hostname on local machine


I have an ASP.NET MVC application that I've been developing and debugging for a while. And when I deploy to a website, it works great.

But something changed and now when I try to run it on my local machine, it compiles and launches the browser with the address http://www.localhost:50821/, but the browser displays an error.

Bad Request - Invalid Hostname
HTTP Error 400. The request hostname is invalid.

I'm really not sure what changed. It was working. Now it doesn't. I'm using the default version of IIS Express that came with Visual Studio 2017.

Any ideas on what I can try?


Solution

  • That URL is bad. Your machine doesn't know how to resolve www.localhost so you get the Invalid Hostname error. Most likely it's supposed to be just http://localhost:50821. Check the Web tab of your project and see if that URL got put in the Project URL somehow. This will cause the debugger to launch with the wrong URL.