Debugging Android Connectivity Issues with Metro Bundler

Whether you just start with or are seasoned React Native developer, chances are you faced the "Unable to load script" error occurring on Android emulator when your app can't connect to the Metro Bundler.

React Native app showing red box with “Unable to load script” on Android Emulator

In this article we’ll explore steps you can take to debug and resolve this dreaded error.

Check Metro Bundler

When you open your app in debug mode and there’s no dev server running (Metro in this case), it’s pretty reasonable to get an error that your app is unable to load script. Ensure that the Metro Bundler by running:

npx react-native start

When the server is running, you should be able to access http://localhost:8081 link from any web browser.

Reverse Port for Emulator

For android emulator to be able to connect to our local dev server, we need to reverse the port on which it listens. Normally it’s taken care of by RNC CLI, RNEF, or Expo, but sometimes it may not kick in properly. In such cases run this command to make sure the emulator can connect to your local dev server hosted on http://localhost:8081:

adb reverse tcp:8081 tcp:8081

If you use different port, please change 8081 to your designated port.

Network Configuration

By default Android apps that target API level 28 or higher will use encrypted protocols to connect with outside world. In our case, we want our app to connect to unencrypted HTTP address localized at http://localhost:8081.

Confirm that your android:usesCleartextTraffic in debug AndroidManifest.xml file is enabled in debug mode. Check or create android/app/src/debug/AndroidManifest.xml to look somewhat like this:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <application
        android:usesCleartextTraffic="true"
        tools:targetApi="28"
        tools:ignore="GoogleAppIndexingWarning"/>
</manifest>

Network Security Config

If your app is configured to use Network Security (located at res/xml/network_security_config.xml), make sure that localhost and 10.0.2.2 (gateway from Android Emulator to your dev machine) are included in your network security configuration:

<domain-config cleartextTrafficPermitted="true">
    <domain includeSubdomains="true">10.0.2.2</domain>
    <domain includeSubdomains="true">localhost</domain>
</domain-config>

Clear Emulator Data

If the issue persists, try wiping data and performing a cold boot on your emulator.

Proxy/Firewall

Make sure no proxies or firewalls are blocking port 8081.

Final Step

If your app builds fine on iOS but not Android, inspect third-party tools and configurations that may affect network settings, such as Proxyman. Remove conflicting configurations and test again. By following these steps, you should be able to troubleshoot and resolve Android connectivity issues effectively. Remember to only enable cleartext traffic in debug variants to maintain app security.

Insights

Learn more about Android

cover

Dec 5Article

Optimize Your Android Application’s Size With Gradle Settings

Learn how to improve TTI, reduce memory usage and size of your Android app by adjusting Proguard rules to your projects.

cover

Jan 22Article

Writing a Native Module for React Native Using Kotlin

Check how to build a react-native-youtube-player, a Native UI component that allows playing YouTube videos in our React Native app.

cover

Mar 24Article

Android Drawer and StatusBar Done Right for React Native

Unlock best practices for Android Drawer and StatusBar implementation in React Native.

cover

Mar 19Tutorial

The Hard Way vs. The React Native AI SDK Way: Stop Writing Custom Modules for Every Model

Learn how React Native AI uses a unified provider model to switch between cloud and on-device LLMs without rewriting application logic, enabling reliable AI experiences online and offline.

cover

Mar 12Tutorial

Build Smarter Apps: Tool Calling & AI Orchestration Explained

Learn how on-device models in React Native can call tools, interact with external APIs, and return structured outputs you can use directly in application logic.

cover

Mar 5Tutorial

MLC LLM + React Native: On-Device AI Without the Pain

Learn how to run third-party on-device LLMs in React Native using MLC LLM. Choose your models, run them efficiently across platforms, and keep a unified JavaScript API with React Native AI.

cover

Feb 24Tutorial

Intelligent Fallbacks with Apple Intelligence in React Native

Learn how to use Apple’s built-in Foundation Models in React Native apps, reduce memory usage, and enable fast, fully on-device AI with React Native AI Apple.

cover

Feb 10Tutorial

What Is the React Native AI SDK? A Complete Intro & Quickstart

Learn why on-device AI matters for React Native apps, how local LLMs behave offline, and what problems React Native AI is designed to solve from day one.

cover

Jan 29Tutorial

Implementing an Android TurboModule with Kotlin

Learn how to implement a React Native TurboModule on Android, from the TypeScript spec and Codegen to the Kotlin implementation and package registration.

cover

Jan 19Tutorial

Working with Different Threads in Swift TurboModules

Learn how JavaScript, native module, background, and main threads interact in React Native TurboModules, and how to use GCD queues to run async work safely in Swift.

cover

Jan 9Tutorial

How to Add Type-Safe Constants to Swift TurboModules

Learn how to expose typed, immutable constants from a Swift TurboModule using Codegen, and get full end-to-end type safety between native and JavaScript.

cover

Dec 30Tutorial

Adding Event Emitters to Your TurboModule in Swift

Learn how to emit native events from a Swift TurboModule and subscribe to them in JavaScript, including proper memory management and Codegen integration.

cover

Dec 22Tutorial

Writing Your First TurboModule in Swift

Learn how to build a fully working TurboModule in Swift, integrate it with Codegen, and bridge it through Objective‑C inside an Expo app.