🚀 Solving React Native Expo CLI Connectivity Issue with Tunnel Mode

🚀 Solving React Native Expo CLI Connectivity Issue with Tunnel Mode

🧩 Problem Faced

While working on my React Native project using the Expo CLI, I encountered a frustrating issue — I couldn't run my app successfully on my physical device using the Expo Go app. Every time I scanned the QR code, nothing happened, or I faced connectivity errors. This kind of issue often arises due to:

  • Network restrictions or firewalls.
  • My device and PC being on different networks.
  • VPN conflicts or local network discovery failure.

🔍 My Debugging Process

Initially, I tried running:

npx expo start        

This starts the Metro Bundler in default LAN mode, which assumes that both my PC and mobile are on the same network.

✅ The Metro server started.

❌ But Expo Go on my phone couldn't connect — QR scanning failed.


✅ The Solution: Using Tunnel Mode

Then I ran:

npx expo start --tunnel        


This time, Expo asked:

The package @expo/ngrok@^4.1.0 is required to use tunnels, would you like to install it globally? ... yes        

After installation, Expo successfully connected the tunnel, and my physical device was finally able to access the project using the Expo Go app!


🛠 What Each Component Does

1. 🧱 npx expo start

This command does the following:

  • Starts the Metro Bundler, which watches your JS/TS files and serves them.
  • Opens a QR code that can be scanned via Expo Go to run the app.
  • Runs in LAN mode by default (unless specified otherwise).

2. 📱 Expo Go

Expo Go is a mobile app (available on iOS/Android) that allows you to preview and run your React Native projects without building a full native app.

  • It connects to the Metro Bundler server and loads your JS bundle.
  • Enables features like Hot Reloading, debugging, and live updates.
  • Scanning the QR code lets you instantly view your app on your phone.

3. 🌐 Tunnel Mode (--tunnel)

By default, Expo uses your local network (LAN) to serve the project. But LAN has issues:

  • Devices on different networks can’t connect.
  • Firewalls may block local IPs.

Tunnel mode solves this by routing your local dev server through a secure public tunnel using ngrok.

4. 🔐 @expo/ngrok

This is a wrapper around the ngrok tool. It:

  • Creates a public URL like https://xyz.ngrok.io that points to your local development server.
  • Makes your local app accessible from any device on any network — even mobile data!

The Expo CLI uses this behind the scenes when you run:

npx expo start --tunnel        

This installs and configures ngrok using the scoped package @expo/ngrok.

5. ⚙️ Metro Bundler

Metro is the JS bundler for React Native. It:

  • Watches for file changes.
  • Bundles your JavaScript code.
  • Sends the JS bundle to Expo Go or a physical/emulator device.


💡 When to Use Each Mode

ModeCommandWhen to UseLANnpx expo startPC and device are on same Wi-Fi & no firewallTunnelnpx expo start --tunnelDifferent networks / firewalls / VPN issuesLocalnpx expo start --localhostWhen only testing on emulator/local browser


🧠 Key Takeaways

  • Always try --tunnel if the default Expo QR code doesn’t work.
  • ngrok makes your local dev environment publicly accessible.
  • Understanding how Expo Go, Metro, and tunneling work together can save a lot of debugging time.
  • Expo simplifies React Native dev, but knowing what's under the hood empowers you to troubleshoot like a pro.


📸 Final Setup Snapshot

npx expo start --tunnel        


# Metro Bundler starts # ngrok tunnel is established # Tunnel ready # QR Code scanned successfully on Expo Go


🔗 Conclusion

React Native development with Expo is super powerful, but sometimes network configurations can throw roadblocks. Thanks to tools like ngrok and Expo's --tunnel flag, you can keep building without frustration.

If you're facing similar issues with Expo Go not connecting, try npx expo start --tunnel — it might just save your day like it did mine!


💬 Let's Connect!

Have you faced a similar issue while developing in React Native? Let’s connect and share solutions! 💬

#ReactNative #Expo #MobileDevelopment #JavaScript #ngrok #FrontendDev #ExpoGo #ReactNativeTips #DeveloperJourney

To view or add a comment, sign in

More articles by Shaik Jaleel Basha

Explore content categories