My phone and pc are in same wifi. When I run ng serve
, I open localhost:4200 in Chrome with my PC, which works.
But I open 192.168.1.107:4200 with my mobile phone, and it doesn’t work.
When I use create-react-app
. It works.
Green is angular. White is react
I'm not sure whether this command changed in Angular 8, but none of these worked for me.
All I had to do was manually specify the port, et voilà!
(Note that you can also use your actual IP address in place of
0.0.0.0
; both worked for me.)Your picture indicates that your PC's IP address is
192.168.1.107
. You stated that you're trying to access your angular app on the following IP:port combination:Assuming this isn't a typo, using the following IP:port combination
192.168.1.107:4200
should allow you to access your angular app.In order to make your server available in local network, you need to use the following command:
And then the app will be available on
192.168.1.107:4200
on every device in your network.If you don't know what is your LAN address you can execute
ifconfig | grep broadcast
on unix-based OS - the first IP is your computer, oripconfig
on Windows machine.ng serve --public-host
(app should run onlocalhost:4200
)You need to do port forwarding, which is thanks to Chrome DevTools realy easy!
Add rule
button which is located inRemote devices
tab in thesettings
(see Tutorial), then intoDevice port
you write4200
and intoLocal address
you enterlocalhost:4200
localhost:5010
, so I simply add new rule like i said aboveDevice Port: 5010
andLocal address: localhost:5010
You can now visit
localhost:4200
on your phone and it should show your appIf your phone and your computer connected to the same network (Wifi, LAN), you can use your computer local IP address (not the public IP address) to connect from your mobile to your computer.
Note: you should allow this in your computer firewall by adding inbound role to allow accessing your computer through your mobile.
Linux machine + Android phone on the same wifi network:
read ufw man page!!! - doing the wrong thing can open your machine to attacks
You may or may not need --disable-host-check