Linux machine + Android phone on the same wifi network:
- Get your machine IP
ifconfig -a
.
.
wlp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.199 netmask 255.255.255.0 broadcast 192.168.1.255
My machine results: network interface wlp3s0, IP 192.168.1.199
- Get your phone IP
consult your phone,
normally in Settings > About device > Status
Result: my phone IP is 192.168.1.196
- Open port 4200 on interface wlp3s0 on your dev machine, your phone IP only, as root:
ufw allow in on wlp3s0 from 192.168.1.196 to any port 4200
read ufw man page!!! - doing the wrong thing can open your machine to attacks
ufw status
Status: active
To Action From
-- ------ ----
4200 on wlp3s0 ALLOW 192.168.1.196
- Serve your app to 192.168.1.199
ng serve --host 192.168.1.199
- Connect from your desktop as well as from your phone to
192.168.1.199:4200
- Alternative - serve to 0.0.0.0
ng serve --host 0.0.0.0
from your machine: localhost:4200
from your phone: 192.168.1.199:4200
You may or may not need --disable-host-check
- Reset your firewall when done
ufw reset
ufw enable
ufw status