I've installed angular-cli with node v6.5.0 and npm v3.10.3 to my vagrant (Scotch) box. After running 'ng serve --port 4201' I can see that the build was successful and that the app is now serving on http://localhost:4201/
However I can't just use above address because I'm running on VM. I've tried to add '127.0.0.1:4201' to hosts file on host machine, but can't get anything working.
Thx
Run ng serve
like this:
ng serve --host 0.0.0.0
This will make the server in your vagrant machine accessible from outside using its ip (mine is 192.168.10.10 using homestead) and the default 4200
port for angular serve
(http://192.168.10.10:4200).
Some more info:
127.0.0.1 is a loopback address so if you assign this IP (or localhost) to the config of your server, its not accessible from other network interfaces, so you cannot access it from outside of the VM. If you bind your server to 0.0.0.0 its available to all interfaces
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With