Ionic 4 angular - Invalid Host header error



Hi, I am trying to run ionic 4 angular app, but can’t solve the Invalid Host header error. I have encountered this problem only on c9 and presume it’s because of the cloud infrastructure.

Here is the public c9 repo:

I have tried to disable host check:

ionic serve --host $IP --port $PORT --public $C9_HOSTNAME --history-api-fallback --disableHostCheck --disable-host-check

or using specific public host:

ionic serve -p 8080 -H --public-host [url]

But none of that (or combination) seems to work :cry:
Can you please point me into right direction?
Thank you very much!


I disabled the host check in the file:

Server.prototype.checkHost = function (headers) { (currently it’s line 617)
I added return true; as the first line in this method.


Thank you @phptechs! It’s working now. :clap:

I am just wondering if version update of webpack would not override the change? Isn’t there some kind of permanent solution, flag or settings?

But thanks for this solution. It certainly did the trick :wink:


Unfortunately, I don’t know about the flags, the one that should work (disableHostCheck) seems to be not working for me.

So for now I’m gonna use this command from the project’s directory (in case webpack got updated or something): :wink:

sed -i -r 's/(Server\.prototype\.checkHost.*)/\1\nreturn true;/' ./node_modules/webpack-dev-server/lib/Server.js


ionic serve -- --disable-host-check babe, you forgot this -- it pass to internal command