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

React Native真机无法连接Metro Server 8081问题求助

Hey there, I’ve run into this exact white screen issue with React Native on physical devices before—super frustrating when it works on simulators but not real ones! Let’s walk through some fixes that usually resolve this:

1. Confirm same network connection for device and computer
  • Make sure your phone and development machine are on the exact same Wi-Fi network (avoid mixing 2.4GHz and 5GHz networks, and turn off any VPNs that might block local connections).
  • Open the developer menu on your device (shake the phone, or use Android’s adb shell input keyevent 82 shortcut/iOS’s Settings > Developer > Shake Gesture). Go to Dev Settings > Debug server host & port for device and manually enter your computer’s local IP address followed by :8081 (e.g., 192.168.1.100:8081).
2. Clear all caches
  • App cache: Uninstall the app completely from your device, then rebuild and re-install it from scratch.
  • Metro cache: Stop the running Metro bundler, then run npx react-native start --reset-cache to wipe cached assets before restarting the server.
3. Check firewall/antivirus interference
  • Your computer’s firewall or antivirus might be blocking the Metro server’s default port (8081). Temporarily disable these tools for testing—if the app connects afterward, add an exception for node.exe or port 8081 in your security software.
4. Platform-specific troubleshooting
  • Android:
    • Ensure USB debugging is enabled on your device, and that you’ve authorized your computer when prompted on the phone.
    • If using Wi-Fi debugging, run adb tcpip 5555 first, then connect your device with adb connect [your device's IP address].
  • iOS:
    • Verify your device shows up in Xcode’s "Devices and Simulators" with no red provisioning errors.
    • If using a free Apple Developer account, check if your app’s provisioning profile has expired—rebuild and re-install the app if it has.
5. Dig for hidden errors
  • Sometimes white screens happen without visible crashes. Try these to uncover issues:
    • Android: Run npx react-native run-android --variant=debug, then use adb logcat *:E to filter error logs from the device.
    • iOS: Open your project in Xcode, run it on your device, and check the "Console" tab for silent errors that don’t show up in the app.

I feel your pain—React Native can be annoyingly finicky with device connectivity, but one of these steps almost always fixes the white screen issue for me. Give them a shot and let me know how it goes!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.06 22:04:06