0

When I run "react-native run-android",it gives me error:"could not connect to development server...".-- The red screen

  • OS: Windows 7
  • node version:8.2.1
  • npm version:4.1.2
  • react-native version:0.47.1
  • react-native-cli version:2.0.1
  • android device and emulator version: 5.1.1

i followed following command:

  • react-native init ProjectName
  • cd ProjectName
  • react-native run-android

And this makes the package server run automatically. But I am not able to access the package server from browser on the machine and the mobile.

My android device connected to computer has debugging enabled i checked it using adb devices command. Usb debug is on.

I tried running the project on real device and on emulator. On Both I got error: "Unable to load script from assets 'index.android.bundle' Make sure your bundle is packaged correctly or you're running a package server'.

reloading i get the error: "Could not connect to development server."

Then i set the host and port number on development setting on both and got the error "Could not connect to development server."

enter image description here

So how to fix the red error screen issue?Any suggestion is appreciated!

1 Answers1

0

Try to open this link in browser. It will automatically bundle the assets.

http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false

You development server should be running while running this command.

Paras Watts
  • 2,565
  • 4
  • 21
  • 46
  • When i try running the command "react-native start". It prompts in the cmd that the "Running Packager on 8081". And when i try browsing the above link it shows me the error: "This site can’t be reached" – Shipra Jain Aug 09 '17 at 10:49
  • Run the command react-native start. After the development server is started successfully open this url in browser. Check if this solves your problem. – Paras Watts Aug 09 '17 at 10:50
  • If packager is already running try killing it and start again. If packager is successfully started then the site can't be reached error will not come. – Paras Watts Aug 09 '17 at 10:54
  • I tried that only. Still no luck. When i run the command react-native start it prompts for Running packager on port 8081; looking for JS FIles in folder; React Packager ready; Loading dependency graph, done. on the command prompt. But still it shows the site cannot be reached. – Shipra Jain Aug 09 '17 at 11:34
  • Try creating assets folder inside android/app/src/main/assets of your recat native project.Then try opening the url – Paras Watts Aug 09 '17 at 11:40
  • Tried but no luck. – Shipra Jain Aug 09 '17 at 14:03
  • Please check if you have followed all the correct steps while setting up react native – Paras Watts Aug 10 '17 at 04:28
  • 2
    All steps followed are rechecked still no luck. – Shipra Jain Aug 16 '17 at 13:31