'How to connect expo go app through docker devcontainer

problem

cannot connect with my expo app to the expo simulation

setup

  • set up a devcontainer with vscode's extension.
  • login into my expo account
  • successful build
  • expo go and laptop in the same network
  • has worked before with last linux pc
  • node -e 'console.log(os.networkInterfaces())' results:
{
  lo: [
    {
      address: '127.0.0.1',
      netmask: '255.0.0.0',
      internal: true,
      cidr: '127.0.0.1/8', 
      ...
    }
  ],
  eth0: [
    {
      address: '172.17.0.3',
      netmask: '255.255.0.0',
      internal: false,
      cidr: '172.17.0.3/16',
      ...
    }
  ]

I tried

  • setting REACT_NATIVE_PACKAGER_HOSTNAME to host's ip
    • without it gives me a link from its eth0
  • open mac's firewall to vscode and docker
  • turn off mac's firewall
  • switch to tunnel connection
    • but this gives an error for another question later
  • tried posting and currently waiting responses here while exercising my google-fu

my environment

mac os 12.3 (monterey)
docker 4.7.1
devcontainer from microsoft's nodejs (alpine with node)
expo cli version: v5.3.2

previous environment

ubuntu 21.04
docker ~4.7.1
devcontainer from microsoft's nodejs (alpine with node)
expo cli version: ~5.3.2

to reproduce

  1. setup a devcontainer

    • "VARIANT": "14-bullseye"
    • "features": {"git": "latest","aws-cli": "latest","desktop-lite": "latest","python": "latest" }
  2. npm i -g expo-cli

  3. expo init a new sample project

  4. expo start

  5. try to connect expo go via the qr

    1. no errors on expo-cli but go-app java.net.ConnectException: Failed to connect to /192.x.x.x:19000
  6. if not working like me:

    1. close expo
    2. export REACT_NATIVE_PACKAGER_HOSTNAME=192.168.1.xxx xxx is host's lan ip address
    3. expo start
    4. try connecting with expo go app via qr
      1. no errors on expo-cli but go-app java.net.ConnectException: Failed to connect to /192.x.x.x:19000


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source