Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Invalid Host header" when running Angular/cli development server c9.io

The --disable-host-check flag works fine if you need to run from Cloud9.

I use the following command:

ng serve --open --host $IP --port $PORT --disable-host-check

In angular.json, add the following under architect -> serve -> options

"disableHostCheck": true

Got the answer from this Github Issue Page


You need to specify the host

ng serve --port 8080 --host 123.34.56.78

See this issue

Edit the following line in node_modules/webpack-dev-server/lib/Server.js (line 425), change to:

return true;

I am using cloud9 IDE then run: ng serve --port 8080 --host 0.0.0.0. Now works fine.


This works for me :

ngrok http --host-header=rewrite PORT

for instance :

ngrok http --host-header=rewrite 4200

In my case, I use my host name to update /etc/hosts file.

vi /etc/hosts

and add your host name last line.

127.0.0.1 myHostName.com

to connect my server,

ng serve -o

An error occurred when connecting to myHostName.com:4200.

so, I did like this,

ng serve --host 0.0.0.0 --disableHostCheck true

Reconnecting to myHostName.com:4200 :)