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

React Native条码示例应用执行run-android后出现503错误求助

Fixing React Native 503 Error After Successful App Installation

Hey there, I know how frustrating it is to get your app installed only to hit a 503 error. Let's walk through some practical fixes that should get your barcode sample app up and running:

1. Make Sure Metro Server is Running Properly

Sometimes the Metro bundler doesn't start correctly when you run react-native run-android. Try this:

  • Open a new terminal window, navigate to your project root, and run:
    npx react-native start
    
  • Wait until you see the "Metro waiting on..." message, then go back to your original terminal and re-run react-native run-android.

2. Clear All Caches (A Common Culprit)

Cached data can often cause unexpected server errors. Run these commands one by one:

  • Reset React Native's cache:
    npx react-native start --reset-cache
    
  • Clean your Android project's build files:
    cd android && ./gradlew clean && cd ..
    

Then try building and running the app again.

3. Verify Device-Metro Connectivity

Your app needs to reach the Metro server on your computer. Here's how to fix connection issues:

  • For physical devices: Ensure USB debugging is enabled, then run this command to forward ports:
    adb reverse tcp:8081 tcp:8081
    
  • For emulators/physical devices: Open the React Native dev menu (Ctrl+M for emulators, shake your device for physical ones), select "Change Bundle Location", and enter your computer's local IP plus port 8081 (e.g., http://192.168.1.5:8081/index.bundle).
  • Double-check that your device and computer are on the same Wi-Fi network.

4. Check for Port Conflicts

Metro uses port 8081 by default—if another app is using it, you'll get a 503 error:

  • Windows: Find the process using 8081:
    netstat -ano | findstr :8081
    
    Kill it with:
    taskkill /PID <ProcessID> /F
    
  • Mac/Linux: Find the process:
    lsof -i :8081
    
    Kill it with:
    kill -9 <ProcessID>
    

Restart Metro after this.

5. Validate Dependencies & Permissions

  • Double-check that your barcode-related libraries (like react-native-camera or similar) are installed correctly and compatible with your React Native version.
  • Ensure your android/app/src/main/AndroidManifest.xml includes the internet permission—this is required for the app to connect to Metro:
    <uses-permission android:name="android.permission.INTERNET" />
    

If none of these steps work, try restarting your computer and device—sometimes a fresh start fixes weird connectivity glitches.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 07:10:05