Home / GitHub Page

Unable to load script/could not connect to dev server - Android emulator

The application compiles without errors and the Android emulator is running properly.

However, when I run react-native run-android, I get the following error:

Screenshot_1563178727

After clicking reload I get another error message:

Screenshot_1563438477

Please note that the Metro Bundler is in fact running on port 8081. (Opening http://127.0.0.1:8081/ with a browser (or curl) gives me: React Native packager is running.)
I also tried the following without success (same error):

  • cleared all node_modules and all Android build files and started over
  • started metro server manually with npm start -- --reset-cache

However, I have no idea where this 10.0.2.2 ip address is coming from. (It’s not my local network, nor is the service running on that ip. It’s running on localhost.)

I’d appreciate any help.

I don’t know as I haven’t had this issue, but maybe on Stackoverflow you’ll get more answers since it’s a generic error.

I’ve spent hours on Stackoverflow and other web sites to research this. The only useful info was to use the statement react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res, which was the only way to get it working. And as you’ve already told me that’s not the solution.

I also tried to set the debug server to 127.0.0.1:8081, but this does not work either.

However, accessing http://127.0.0.1:8081/index.android.delta?platform=android&dev=true&minify=false on my host and within the emulator’s browser yields a response from the metro server.

I just hope that someone with react-native experience and this project might have an answer. I guess only time will tell. Until then, I will have to use this rather akward “bundle” workaround, which is detrimental to any real development work.