0

On my local laptop I have a bunch of sites running using docker and made accessible in my /etc/hosts like so:

> 127.0.0.1       www.example.local
> 127.0.0.1       api.example.local
> 127.0.0.1       connect.exampe.local

Using Ionic I am emulating android: ionic cordova emulate android

Now when I got the browser on the android and I type it in www.example.local, I cannot access the site. But it works fine from my local. I assumed they would be using the name network settings. What configuration am I missing?

ankuranurag2
  • 2,300
  • 15
  • 30
Devin Dixon
  • 11,553
  • 24
  • 86
  • 167

1 Answers1

0

I would imagine this device is acting in similar fashion as a virtual machine. In which case, the network is bridged but different. 127.0.0.1 on this device likely points to the device itself. You will need to find (or create) the ip of your computer that your device is familiar with

If you are running on a mac, you can use the following commands to create an alias to the loopback adapter which the device should be able to see.

(NOTE: the dns you setup in /etc/hosts may not work)

ifconfig lo0 alias 172.16.123.1 # Allows emulator to use 172.16.123.1 for localhost
ifconfig lo0 -alias 172.16.123.1 # removes alias

Source of this info: https://stackoverflow.com/a/624660/1991100

Realistic
  • 1,038
  • 1
  • 10
  • 20