Reputation: 593
I'm trying to test my "Angular 2 Final" (1.0.0-beta.15) app on my other mobile devices an PCs, but I cannot get to work the 192.168.0.xxx:4200 address, only the localhost:4200... not even in my development Mac.
When I use localhost:4200 everything works fine, the issue is with the IP version.
I'm updating from the angular beta 2.0.0-beta.6 when the port used to be 3000.
I tried changing the port to 3006 with: ng serve --port 3006
but the same issue.
Thanks a lot for the help!
Upvotes: 3
Views: 11418
Reputation: 1262
Run command " ng serve --host=0.0.0.0 --disable-host-check "
this will disable the host check and make your port accessible with IP address
Upvotes: 0
Reputation: 4335
Just specify the IP in --host option like ng serve --host 192.16.1.1
Now you can visit http://192.16.1.1:4200
in your browser and it will work
Upvotes: 11
Reputation: 4478
As of version angular-cli: 1.0.0-beta.15
.
First of all, localhost (or 127.0.0.0
) and 192.168.x.y
are different network interfaces.
The node.js server started by ng serve
listens only on 127.0.0.1
(aka localhost) with port 4200
. Thus it doesn't accept requests to your local network IP (192.168.x.y
). You can check it via netstat
or similar utility.
If you want the node.js to listen on all accessible interfaces (aka IP 0.0.0.0
) you can do this by specifying the listening IP explicitly by ng serve --host 0.0.0.0
.
I've created an issue so you can track it: https://github.com/angular/angular-cli/issues/2275
Upvotes: 6