1

I'm working on a react native app from a windows 10 computer. I installed WSL, set up my backend needs on it, and I can see my api responding on localhost from windows, no problem on that end.

Now I would like to call it from my mobile app - both from an android emulator using Android Studio and from my physical android device (using Expo) connected to the same local network over wifi.

Using Ngrok it could work, exposing my localhost to a public url, but that's not what I'm looking for. I want it all to remain local if possible. My pc's local ipv4 is 10.0.0.8, but nothing comes out on that address (not from the mobile app neither from my desktop browser, which works on localhost).

My Ubuntu inside WSL says:

~$ cat /etc/hosts

# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateHosts = false
127.0.0.1       localhost
127.0.1.1       JB-PC.localdomain       JB-PC

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

My ipconfig:

Carte Ethernet Ethernet :

   Suffixe DNS propre à la connexion. . . : Home
   Adresse IPv6 de liaison locale. . . . .: fe80::f04e:ae2b:40b9:3d82%6
   Adresse IPv4. . . . . . . . . . . . . .: 10.0.0.8
   Masque de sous-réseau. . . . . . . . . : 255.255.255.0
   Passerelle par défaut. . . . . . . . . : 10.0.0.138

Carte Ethernet vEthernet (WSL) :

   Suffixe DNS propre à la connexion. . . :
   Adresse IPv6 de liaison locale. . . . .: fe80::68c3:25c9:588a:a957%17
   Adresse IPv4. . . . . . . . . . . . . .: 172.20.32.1
   Masque de sous-réseau. . . . . . . . . : 255.255.240.0
   Passerelle par défaut. . . . . . . . . :

What IP address and what port should I use to access the API from the phone or the emulators? Also, is there something else I need to do on my ubuntu to expose it so it's usable?

1
  • 1
    This is most likely the same root question seen here, with the same suggested workarounds I gave there. Although, Ngrok is a good idea as well for others that could probably be added to that answer (feel free to edit), even if it doesn't work for your use-case. If that answer works for you, consider upvoting the question and answer there (and close this question). If not, let me know in a reply comment here and we'll see if we can figure it out. Apr 17 at 23:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.