Could not connect to React Native development server on Android

前端 未结 28 1963
鱼传尺愫
鱼传尺愫 2020-11-30 22:10

When I run react-native run-android, it gives me the following error:

Could not connect to development server

28条回答
  •  执笔经年
    2020-11-30 22:23

    Solution for React-native >V0.60

    You can also connect to the development server over Wi-Fi. You'll first need to install the app on your device using a USB cable, but once that has been done you can debug wirelessly by following these instructions. You'll need your development machine's current IP address before proceeding.

    Open a terminal and type ipconfig getifaddr en0 For MAC

    Make sure your laptop and your phone are on the same Wi-Fi network. Open your React Native app on your device.

    You'll see a red screen with an error. This is OK. The following steps will fix that.

    1. Open the in-app Developer menu. shake your phone or press CMD/ctrl + M
    2. Click on Settings
    3. click on Debug server host & port for device
    4. On popup Type your machine's IP address and the port of the local dev server (e.g. 10.0.1.1:8081).
    5. Go back to the Developer menu and select Reload.

    DONE

提交回复
热议问题