Skip to main content

Deals You Can't Miss

1 Year Subscription

Connecting to Expo Dev Server in WSL 2 over LAN

This post drafts things I did to connect my Android device to Expo dev server running in WSL 2 on Windows 10 over LAN connection (in my case using Wi-Fi). The set-up looks like below:


Note: Expo-Client is installed on my android device.

Note: Expo-CLI npm version used is 3.27.14

Assumption: IPv4 address is used over IPv4.

When you run `ip address` in your WSL 2 terminal, you will your ip-address of your VM as something like  172.x.x.x.

When you check the ip address of your Windows 10 host, by running `Get-NetIPConfiguration` in your PowerShell terminal you will find your host ip to be something like 192.168.x.x. When you connect your Android device to the same LAN over Wi-Fi, your ip address would be similar (something like 192.168.x.x).

The fact that WSL 2 isn't sharing the same ip address as its host is an issue to be resolved. This needs to be fixed as first thing, because otherwise how do we even reach the server running in WSL over LAN? The easy fix to this is to prefix your server start command with your windows host ip like `REACT_NATIVE_PACKAGER_HOSTNAME=your_windows_host_ip`. In my case I run the expo server like `REACT_NATIVE_PACKAGER_HOSTNAME=192.168.10.12 expo start`.

Your expo server runs in port ranges of 19000-19006. Make sure your WSL firewall isn't blocking these ports. I have Ubuntu 20.x as my WSL 2 VM. I check to see if my firewall is active and if active are the mentioned ports listed and open by running the command `sudo ufw status verbose`. In my case the firewall status is inactive as expected. Note that using a firewall in WSL is redundant and should you choose to have it activated, you can add those mentioned ports using the command `sudo ufw allow $PORT`, where $PORT is the port number that you want to add to firewall rules to open it up.

You also need to do port forwarding of the mentioned ports on windows host operating system. You can use netsh on your Powershell in admin mode. The cookbook for it will be below commands:
  • List all your portproxy rules: `netsh interface portproxy show v4tov4`.
  • Remove all your portproxy rules: `netsh int portproxy reset all`.
  • Forward Ports into WSL2 :  use the net shell "netsh" to add a portproxy rule. Again, change connectaddress to YOUR WSL2 ipaddress, which is an internal address to your machine.
    netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=19000 connectaddress=127.0.0.1 connectport=19000
  • Open The Firewall: Next, from the same Administrator Windows prompt, open an incoming Firewall Port. You can do it from the Advanced Firewall Settings, but even easier you can use netsh again!
    netsh advfirewall firewall add rule name="Open Port 19000 for WSL2" dir=in action=allow protocol=TCP localport=19000
In an ideal world this should get you going. In my case though, doing all these still didn't help me and I had to resort to tunneling and making use of expo's platform for this.


My Popular Posts

Ten Commandments of Egoless Programming

We are nothing but the values we carry. All through my life thus far, I tried to influence people around me with the virtues I value. Thanks to some good reading habits I had inculcated, and the fortune of being in good community of peers and mentors alike, I managed to have read some real good books. This post is about the 10 commands of egoless programming in Weinberg's book. I shall explain the commandments based on my experience here. So very many decades ago, Gerald M. Weinberg authored  The Psychology of Computer Programming . In it, he listed The Ten Commandments of  Egoless Programming , which remains relevant even today for us as not just programmers but as team-members. Weinberg is regarded as a pioneer in taking a people-centric approach to computing, and his work endures as a good guide to intelligence, skill, teamwork, and problem-solving power of a developer. When they appear to inspire and instruct, we find that they can apply to just about every business area, and e

Should I buy refurbished laptop from Amazon?

This post is based on my experience with amazon.in and guess it to be true on all other platforms as well. At least you can check out and verify for these pointers before you make that decision to buy renewed/refurbished laptop on Amazon with your hard earned money. I see this question propping up in several forums and on many different occasions. In the recent past, I had my 5 year old dell laptop that gave up because its motherboard failed. One of the options that I had in my mind was to re-use the HDD and the 16GB DDR4 RAM of that old laptop in the one that I purchase next as secondary.  I had come to a conclusion that it is not worth buying a refurbished/renewed laptop at all. Why? For the following reasons, most of which I see as BIG #RedFlags: You got to remember that Amazon provides a platform for 3rd party sellers to sell their products as well. So in your search for refurbished laptops you wouldn’t want to choose some random 3rd party seller who Amazon doesn’t endorse. You cou

Multi-tenant Architectures

  Multi-tenancy Application Deployment Architecture could be modeled in 4 broad ways: Separate Apps & Separate Databases Shared Apps & Shared Databases Separate Apps & Shared Databases Shared Apps & Separate Databases There is no right or wrong here. It's about choice and consequence that you should consider taking into your business context and constraints. In this post I intend to jot down a some key points to keep in mind for each of these multi-tenant architecture. These are more of quick notes for my quick reference, a cheat-sheet of sorts when I have to make choices. And I guess this can come handy to you too in your wise decision making. Separate Apps & Separate Databases Easiest to implement from development and deployment stand-point. Just automate the deployment infrastructure for every tenant for quick set-up. Most expensive of all the models from infrastructure cost stand-point. Relatively longer deployment t