How to run my Angular site on mobile device that is running localhost on my windows desktop
try ng serve --host
option as explained in this issue: https://github.com/angular/angular-cli/issues/1793 comment by intellix.
ng serve --host 0.0.0.0
- Find your local IP address by following this
- Navigate to
<local IP adress>:4200
from any device on the same network.
NOTE: If you get CONNECTION_REFUSED just disable your firewall and you should be good to go.
otherwise, try https://ngrok.com/ to open a tunnel from your local network to your computer's localhost. Basically your computer forwards the 4200 port to an external IP and port that any device on the network can access.
First verify your machine IP Address.
- On Windows, type
ipconfig
in Prompt (copy IPv4). - On Mac, type
ifconfig |grep inet
in Terminal (copy inet).
In my case this is192.168.0.10
.- On Windows, type
Next, type
ng serve --host 192.168.0.10
.Ok, your app on air for all devices on same network.
Now only
http://192.168.0.10:4200/
will work,localhost
not more.
When i tried using
ng serve --host local ip address
I was facing
Invalid header Request
This issue was solved using --disable-host-check
ng serve --host local ip address --disable-host-check