Use correct ethernet adapter when using create react native app (CRNA)

So i stumbled over a problem when creating a new react native app with CRNA (create-react-native-app)  which otherwise is amazing to get started fast  with prototyping and build ios apps on your windows machine.

When you first create and run your app

You will get a QR-code to scan with the expo app on your phone. The builder will bundle the javascript on the fly and preview the app on your phone with live reloading.

One problem tho, you need to be on the same network on your phone as the builder, well that’s not really a problem but it became a problem for me because i run a lot of VMs on my machine and have VirtualBox and Hyper-V installed and running.

This gives me a lot of virtual ethernet adapters and the builder just selects the first one. That gave me some random ip like 172.115.56.77:19000 and I’m not on that network on my phone.

So how do we fix this? You need to set the interface metric on the adapter you want to be first.

After that is done you can just run yarn start again and now you will see that it’s the correct adapter.

Happy coding!

Sharing is caring!

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.