1

I'm just starting to build an Ionic 2 app, but I can't get it working on my mobile device.

Python (works)

To demonstrate that the phone can see the host, I tried a Python server:

$ python -m SimpleHTTPServer 8000
Serving HTTP on 0.0.0.0 port 8000 ...

If I go to http://192.168.8.101:8000 on my phone, it connects fine and displays the directory listing.

Node (fails)

However, when I start Ionic:

$ ionic serve -p 8000
[...]
[INFO] Development server running
       Local: http://localhost:8000
       External: http://192.168.8.101:8000

I can load it in my host's web browser, but I can't see it from my phone nor another computer (it times out). I also tried a basic node server:

$ npm install http-server -g
$ http-server -p 8000
Starting up http-server, serving ./
Available on:
  http://127.0.0.1:8000
  http://192.168.8.101:8000

With the same result as Ionic: accessible from the host, but not from the phone.

Is there something blocking the request? Or is there some Node configuration I'm missing? I'm new to both Mac OS and Node, so I don't know where to look.

z0r
  • 6,975
  • 4
  • 50
  • 72
  • on my ubuntu laptop using node v8.4.0 my 192 IP is visible from my phone sharing same wifi router ... not sure what you mean by external as any of this is internal to the local network – Scott Stensland Sep 08 '17 at 00:59

2 Answers2

1

Embarrasingly, this turned out to be a firewall issue. In System Preferences > Security & Privacy > Firewall > Firewall Options, Node was explicitly set to deny incoming connections:

enter image description here

Changing it to Allow has fixed it. Phew!

z0r
  • 6,975
  • 4
  • 50
  • 72
0

Just execute ionic address and you'll get an IP address in your command line. Try with that ipaddress:port number from your mobile which will enable you to access your site from your phone.

Just incase if the ionic address command doesn't return anything, you need to execute the below command to point it to your ip,

ionic serve --address YOUR_IP_ADDRESS

Hope this helps!

David R
  • 11,004
  • 7
  • 44
  • 63
  • Thanks - but using `--address 192.168.8.101` didn't help. Also the version of Ionic I'm using doesn't have the `address` command (it's not listed in [the docs](https://ionicframework.com/docs/cli/) either). – z0r Sep 06 '17 at 07:54