Could not connect to development server error solved
In this article, we going to learn about the common error in the react-native which is could not connect to development server error, React-native project run’s on backend server which builds our code directly and reflect on screen for this you need to start-server using command npm start and after server successfully start you need to apply react-native run-android for android, react-native run-ios for iOS after running these command you project will build successfully and try to connect to server but if you device could not connect to server then it will display the following error could not connect to development server as you can see in following screenshots
1. You need to fix the following issues to solve this error
- First, check whether your device is properly connected to the computer and has USB debugging is enabled.
- Second, check the development server’s(npm start) dependency graph is successfully started and Done.
- If you connected by wifi then check your device and the server computer is in the same wifi network.
- If you are using a mobile(physical device) device then just run adb reverse tcp:8081 and then run react-native run-android to run the project on the physical device.
- Still, you are giving an error then, on the device you need to open react-native dev settings for windows press Ctrl+M to open dev settings whereas for Mac(iOS) Cmd+R to open dev settings, the dev popup looks like below
- for the physical device, you have to shake your mobile to open the react-native dev menu settings. you will see above popup select Dev Settings option then click on Debug server host & port for device you will see the following popup
- As you see in the above screenshots, you need to add your pc IP address with the port number to connect with server