Background
Most developers often use two or more desktops and laptops when they're working on a project. Same for me, and now I'm working on an Angular project.
GOAL
I want to access localhost:4200 from another device, so I can check the UI updates without switching windows on a device.
I took some research and tried the below angular-CLI command.
ng serve --host=MyLocalIP ng serve --host 0.0.0.0
But no luck until yet. Is there a better way to achieve this?
Using ng serve --host 0.0.0.0
command has solved my problem. Type 192.168.x.x:4200 to get access to the app from another machine.
Also, check for firewall rules on client and server (disable firewall temporally or create a rule to allow traffic)
Two options are there
ng serve --host 0.0.0.0
To check, if this is not working, 1st try to hit from the same computer where you rung ng serve, to get to know if you can access through the firewall
ng serve --host 192.168.X.X
192.168.X.X is the IP address of my pc(you can use ipconfig(windows), ifconfig(Linux) to see your IP) After that, you can access 192.1668.X.X:4200 instead of localhost:4200
Nothing related:- Even if you change some code and server refresh to show updated code, it will refresh in other machines too
If you can not able to access 192.168.X.X:4200. You may be in a network where firewall protection is blocking. SO, connect to your personal network and check
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