I have an issue while debug my app which is build by react native. Whenever i started to build, it gives me error that could not connect to development server. I tried various solutions like upgrading npm, clearing watchman cache, restarting npm. None of them is working. Any help is most welcome!!!
Try this. Open another terminal and run, react-native start — reset-cache. Then run, react-native run-android on your current terminal.
Try the following to fix the issue : Ensure the packager server is running. Ensure your device/ emulator is connected to your machine and has USB debugging enabled – run 'adb devices' to see a list of connected devices.
Metro is a development platform for React Native. This project acts as a JavaScript bundler; it manages assets, caches builds and performs hot module reloading. Metro focuses on improving the developer experience for the React Native community.
I know Answer is late. but this works for me everytime.
# Clean cache
rm -rf $TMPDIR/react-*; rm -rf $TMPDIR/haste-*; rm -rf $TMPDIR/metro-*; watchman watch-del-all
# Open a new tab and Start Metro Bundler directly from the project folder
react-native start --reset-cache
# Now run `react-native run-android` or `react-native run-ios`
Original Link
I've got the same issue today (out of the blue). Works like a charm before, but then it doesn't work anymore after I've upgraded react-native to from 0.58.8 to 0.60.5.
I figured out, that I got two network-devices with different IP addresses, if I type ifconfig
into the Terminal: en0 with an 192.xxx address, and en1 with an 162.xxx Address.
The error at my device show, that it try to connect to the 162.-Address.
After all, I've solved it with a change in AppDelegate.m
like that:
// Workaround for local IP:
return [NSURL URLWithString:@"http://192.168.178.62:8081/index.bundle?platform=ios"];
// return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
Choose your own IP for the http-Address and give it a try. To check, if you can access the Packager-URL, you also can give it a try in your Browser.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With