What is this “Invalid Host Header” error?

Avinash Thakur
2 min readJun 20, 2019

In the course of testing an application hosted on your local machine, you may receive an “Invalid Host Header” error message when testing on CrossBrowserTesting using a local connection. This error is most commonly caused by a misconfiguration of the application server that causes it to reject non-local connections.

What’s going on?

Most development-oriented application servers (such as ng, webpack-dev-server, or WAMPP) default to only bindingto localhost (or in some cases blocking traffic directly). Essentially, only traffic directed to your machine from itself is allowed to pass through, meaning that traffic passing through the tunnel will not work the same as traffic coming from your machine directly. Even though it works on your machine, the way the server is set up makes it so that even other local machines cannot connect to it.

How do I fix it?

In most cases, the fix is to tell the server to restart and allow connections from outside localhost.

ng (Angular)

Kill the server and restart it, adding --host 0.0.0.0 --disableHostCheck true to the command.

Angular2

Same as above, but add --host 0.0.0.0 --disable-host-check instead

webpack-dev-server

Kill the server and restart it, adding --host 0.0.0.0 to the command.

--disable-host-check is sometimes needed here as well.

--

--