Could not connect to React Native development server on Android

前端 未结 28 1953
鱼传尺愫
鱼传尺愫 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:33

    If you are trying to debug app in your physical android device over wifi using a windows machine, then the device may not be able to access the port of your pc or laptop, you have to make the port accessible. this involves two steps:

    1. First create a rule in firewall. for doing this follow the following steps:

      • open run dialog
      • type wf.msc
      • click on inbound rules
      • click new rule on right hand side
      • select port from pop up menu and click next
      • select tcp port and specific local ports and enter the port number like 8081 (default)
      • allow the connection
      • select all in profile section
      • give some appropriate name and description
      • click finish
    2. you have to make your pc accessible to outside, for doing this follow the following steps:

      • open network and sharing centre from control panel
      • change adapter settings
      • select your wifi network
      • right click, properties
      • click on sharing tab
      • check all the checkboxes

    You are good to go, now try running react-native run-android.

提交回复
热议问题