使用Expo测试Android应用时遇SocketTimeOutException问题求助
Hey there, let's work through this Expo connection issue together—socket timeouts can be tricky, but we've got a few more angles to check:
Double-check Wi-Fi alignment: Make sure your Android phone and computer are connected to the exact same Wi-Fi network (same SSID, same frequency band—2.4GHz vs 5GHz can block cross-communication even on the same router). It's an easy oversight but super common.
Manually specify your computer's IP for Expo: Sometimes Expo auto-detects the wrong local IP. First, find your computer's local LAN IP:
- Windows: Run
ipconfigin Command Prompt, look for "IPv4 Address" under your active Wi-Fi/Ethernet adapter. - Mac/Linux: Run
ifconfigorip addrin Terminal, find the inet address for your connected network.
Then start Expo with this IP:expo start --host [your-local-ip](replace the bracket part with your actual IP), then scan the new QR code.
- Windows: Run
Verify full firewall access for port 19000: You mentioned opening the firewall, but make sure both inbound and outbound rules allow traffic on port 19000. Also, some third-party antivirus tools (like McAfee, 360 Security) have their own firewalls that might override system settings—try temporarily disabling them to test.
Switch to Expo Tunnel Mode: If LAN connections keep failing, tunnel mode routes traffic through Expo's cloud servers, bypassing local network issues. Start your project with
expo start --tunneland scan the generated QR code—this should work even if there are LAN configuration problems.Disable extra network adapters: Beyond VirtualBox, other virtual adapters (like VPN, Docker, or Hyper-V) can mess with Expo's IP detection. Go to your computer's network settings and disable all adapters except the one you're using for Wi-Fi/Ethernet, then restart Expo.
Reset your Expo session: Close the Expo server in your terminal, force-quit the Expo Go app on your Android phone, then restart both and try scanning again. Temporary glitches often clear up with a fresh start.
内容的提问来源于stack exchange,提问作者Jan D.M.

