Exposing localhost to the internet via tunneling (using ngrok): HTTP error 400: bad request; invalid hostname Exposing localhost to the internet via tunneling (using ngrok): HTTP error 400: bad request; invalid hostname asp.net asp.net

Exposing localhost to the internet via tunneling (using ngrok): HTTP error 400: bad request; invalid hostname


Troubleshot this issue with ngrok. In the words of inconshrevable, some applications get angry when they see a different host header than expected.

Running the following command should fix the problem:

ngrok http [port] -host-header="localhost:[port]"


Following command will fix the issue

ngrok http -host-header=localhost 8080


This didn't work for me. you could do the following:

For IIS Express

In VS 2015:Go to the .vs\config\applicationhost.config folder in your project

In VS 2013 and earlier:Go to %USERPROFILE%\My Documents\IISExpress\config\applicationhost.config

Find the binding that says:

<binding protocol="http" bindingInformation="*:5219:localhost" />

For me it was a project running on port 5219

change it to

  <binding protocol="http" bindingInformation="*:5219:" />

IIS Express will now accept all incoming connections on that port.

Disadvantage: you need to run IIS Express as admin.

or you could rewrite the host header in Ngrok:

ngrok.exe http -host-header=rewrite localhost:5219