You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native安卓真机调试卡在“loading from localhost:8081”求助

Fixing React Native Android App Stuck on "Loading from localhost:8081" White Screen

Hey there, sorry to hear you're stuck with this frustrating white screen issue—especially since it was working fine before and even the fresh Demo app is having the same problem. Let's walk through some targeted fixes that usually resolve this exact scenario:

1. Verify Localhost Connection & Port Access

  • First, double-check that your computer and Android device are on the same Wi-Fi network (or that USB debugging has proper port forwarding set up).
  • Run this command to confirm the Metro bundler is actively listening on port 8081:
    lsof -i :8081
    
    If no results pop up, restart the Metro server with a cache reset:
    npm start -- --reset-cache
    
  • For USB debugging, re-establish reverse port forwarding (this often drops unexpectedly):
    adb reverse tcp:8081 tcp:8081
    

2. Rule Out Network Blocks & Device Settings

  • On your Android device, go to Settings > Developer Options > Debugging and confirm "USB debugging" is enabled. If Developer Options are hidden, head to About Phone and tap "Build Number" 7 times to unlock them.
  • Temporarily disable any VPN or firewall on your computer—these often block the Metro bundler's port without warning.
  • Test the connection directly on your device: open a browser and try accessing http://localhost:8081 (or your computer's local IP, like http://192.168.x.x:8081). If the Metro welcome page loads, the connection is solid; if not, there's a network block to fix.

3. Reset Cache & Clean Stale Builds

  • Clear the React Native cache entirely to eliminate corrupted cached files:
    npx react-native start --reset-cache
    
  • Clean the Android build folder to remove outdated artifacts:
    cd android && ./gradlew clean && cd ..
    
  • Rebuild and run the app from scratch:
    npx react-native run-android
    

4. Adjust Metro Bundler & Device Debug Settings

  • Try starting Metro with the port explicitly specified to rule out port conflicts:
    npx react-native start --port 8081
    
  • If localhost still isn't working, switch to your computer's local IP on the device: shake the device to open the developer menu, go to Dev Settings > Debug server host & port for device, and enter your computer's IP followed by :8081 (e.g., 192.168.1.105:8081).

5. Update Dependencies & SDKs

  • Outdated tools can cause odd connection bugs. Update your React Native CLI:
    npm install react-native@latest
    
  • Open the Android SDK Manager and make sure you have the latest build tools, platform SDK, and emulator images installed.

If all else fails, try a full reboot of both your computer and Android device—sometimes a simple restart fixes hard-to-trace network glitches.

内容的提问来源于stack exchange,提问作者Harini

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 04:05:13