React Native runs on backhand server which starts when we apply the react-native run-android or react-native run-ios command on our command prompt screen. This command start will build up our Gradle project and start synchronizing the whole package using JS server. So when we close the server window this development server Error occurs.
Could not connect to development server error should look like below image :
The message with this error should look below :-
Could not connect to development server.
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.
- Ensure airplane mode is disabled.
- If you’re on a physical device connected to the machine , run ‘adb reverse tcp:8081’ to forward request from your device.
- If your device is on the same Wi-Fi network, Set ‘Debug server host & Port for device’ in ‘Dev settings’ to your machine IP address and the port of your local Dev server – e.g. 10.0.1.1:8081 .
How to Solve Could not connect to development server Error in React Native :
1. This error occurs when we close the server command prompt window by mistake . The server command window should look like this :
2. So there is no need to close and recompile the whole project again. All you have to do is select your command prompt window ” In which you have applied the react-native run-android ” command.
3. Type react-native start command like i did in below screen shot. This command should start your development server instantly. Now just press twice the R key to again run your project on emulator.
Here you go now your error should solve. 🙂