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 82shortcut/iOS’s Settings > Developer > Shake Gesture). Go toDev Settings > Debug server host & port for deviceand 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-cacheto 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.exeor 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 5555first, then connect your device withadb 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.
- Sometimes white screens happen without visible crashes. Try these to uncover issues:
- Android: Run
npx react-native run-android --variant=debug, then useadb logcat *:Eto 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.
- Android: Run
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
相关产品推荐
相关产品推荐

