Solvedangular cli ng serve doesn't listen other than localhost
โ๏ธAccepted Answer
Works with command ng serve --host 0.0.0.0
Other Answers:
@sshreya0808 I may have had the same "Invalid Host Header" problem as you did. The cause of this problem may or may not have been because AWS remote server/VPS has some default firewalls/security settings that may happen to obstruct simply testing Angular's CLI-installed "Welcome to app!" page.
To fix this on my AWS instance, without enabling production, I simply ran:
ng serve --port 8080 --host 0.0.0.0 --disableHostCheck true
, then navigated from Safari/Chrome to the IP address I associated with my instance in the "Elastic IPs" section of my AWS dashboard -- plus the port I specified (e.g. "142.43.53.12:8080/").
@levivel
yeah, ng serve --port 8080 --host 0.0.0.0 --disableHostCheck true
it works for me.
thanks
@gyuho Hi have you found the cause which package or making the app bind to 127.0.0.1 and not other IPs? I have to run --host 0.0.0.0 as well to make it work on VM.
@ninjadev1030 solution with --host 0.0.0.0 --disableHostCheck true
works even in Angular 6! Thanks for this.
Ubuntu 16.04
ng --version
. If there's nothing outputted, please runin a Terminal:
node --version
and paste the result here:do on your code? etc.
I have this app https://github.com/jelbourn/material2-app.
And just type
npm start
in repository root. Both in remote and local machine, I seeBut when I try to connect to
http://[PUBLIC_IP_ADDRESS_OF_CLOUD]:4200
, it doesn't serve. I checked all network settings (I am using Google Cloud VM) and confirm that there's no firewall blocking:4200
.Same simple webserver in Go listening to
:4200
works fine on the same machine.Is there anything that I am missing to deploy angular app in virtual machines?