Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Expo-start in dev-container with MacOS gives the wrong lan link ip #4307

Closed
O1H9 opened this issue Apr 15, 2022 · 8 comments
Closed

Expo-start in dev-container with MacOS gives the wrong lan link ip #4307

O1H9 opened this issue Apr 15, 2022 · 8 comments
Labels
needs review Issue is ready to be reviewed by a maintainer

Comments

@O1H9
Copy link

O1H9 commented Apr 15, 2022

Summary

Coding with Visual Studio Code and Dev Container, upon expo start, metro sets a link unreachable. my pc has a 192.168.X.X ip, metro sets 172.17.0.3 .

expo start happens into the dev-container.

This works on Ubuntu's Laptop, in the same network, and the same dev-container (almost: current pc needed 'bullseye' version), but doesn't work on MacBook.

node -e 'console.log(os.networkInterfaces())'
{
  lo: [
    {
      address: '127.0.0.1',
      netmask: '255.0.0.0',
      family: 'IPv4',
      internal: true,
      cidr: '127.0.0.1/8',
      ...
    }
  ],
  eth0: [
    {
      address: '172.17.0.3',
      netmask: '255.255.0.0',
      family: 'IPv4',
      internal: false,
      cidr: '172.17.0.3/16',
      ...
    }
  ]
}```


### Environment

expo-env-info 1.0.2 environment info:
System:
OS: Linux 5.10 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
Shell: 5.1.4 - /bin/bash
Binaries:
Node: 14.19.0 - /usr/local/bin/node
Yarn: 1.22.17 - /usr/bin/yarn
npm: 8.6.0 - /usr/local/share/npm-global/bin/npm
npmPackages:
expo: ~44.0.2 => 44.0.6
react: 17.0.1 => 17.0.1
react-dom: 17.0.1 => 17.0.1
react-native: 0.64.3 => 0.64.3
react-native-web: 0.17.1 => 0.17.1
npmGlobalPackages:
eas-cli: 0.50.0
expo-cli: 5.3.1
Expo Workflow: managed


### Please specify your device/emulator/simulator platform, model and version

MacOS Monterey 12.3.1 ––> alpine Dev-Container nodejs 14 bullseye

### Error output

_No response_

### Reproducible demo or steps to reproduce from a blank project

1. In a MacBook, the same version as the one described, create an expo project.  
1. using microsoft dev-container extension in vscode create and open the dev-container   
1. expo-start in terminal  
1. try to connect.
@O1H9 O1H9 added the needs review Issue is ready to be reviewed by a maintainer label Apr 15, 2022
@O1H9
Copy link
Author

O1H9 commented Apr 15, 2022

Note: working with DevContainers in Ubuntu gave me no problems whatsoever as vscode forwarded the right ip and port. With this Macbook i got only localhost working so i am able to open the metro page.

@O1H9
Copy link
Author

O1H9 commented Apr 15, 2022

Also note that i also am using dev-containers to develop a angular app, and it works just just fine with ng-serve, it uses localhost

@O1H9
Copy link
Author

O1H9 commented Apr 20, 2022

Made a stackoverflow's question, linking here for anyone who will have the same problem (but it's still unresolved, please keep this open)

@O1H9
Copy link
Author

O1H9 commented Apr 20, 2022

tried

  • without macos firewall
  • setting up REACT_NATIVE_PACKAGER_HOSTNAME
  • tunnel connecion
    • doesn't work, but it's for another time

I don't know what to look for anymore but i'm looking for some docker nat explanation/solution and some way of docker port mapping

@kbrandwijk
Copy link
Member

I use VS Code Remote Containers, and setting REACT_NATIVE_PACKAGER_HOSTNAME to the IP of my host works fine for me. I set it up as part of the docker container definition, but you should be able to run REACT_NATIVE_PACKAGER_HOSTNAME=192.xxx.yyy.zzz expo start or whatever your host IP is. Also make sure that if you use a dev-container, that you have port forwarding set up for 8081, 19000-19002.

@O1H9
Copy link
Author

O1H9 commented Apr 20, 2022

but you should be able to run REACT_NATIVE_PACKAGER_HOSTNAME=192.xxx.yyy.zzz expo start or whatever your host IP is.

thanks, I just tried but doesn't seem to work. I got the same behaviour like exporting REACT_NATIVE_PACKAGER_HOSTNAME before expo start

Also make sure that if you use a dev-container, that you have port forwarding set up for 8081, 19000-19002.

about that, i checked vscode forwarded port and found only 19000 and 19002. I promptly added 8081 as you pointed out but didn't change the result

@O1H9
Copy link
Author

O1H9 commented Apr 20, 2022

also just found out exactly how expo-go fails with java.net.ConnectException: Failed to connect to /192.x.x.x:19000

@byCedric
Copy link
Member

byCedric commented Jan 5, 2024

Hi @O1H9! You would need additional configuration for WSL2 to allow connections from other devices, other than your computer, into the WSL2 environment.

There are different approaches to this:

Hope this helps!

@byCedric byCedric closed this as completed Jan 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs review Issue is ready to be reviewed by a maintainer
Projects
None yet
Development

No branches or pull requests

3 participants