Could not connect to development server [React-Native] - react-native

I create a vanilla react-native application, then I run it using Xcode and the react-terminal window opened but when I try to enable "Fast refresh" from app-in-menu it doesn't show the option, so I tap on "Configure Bundle" using IP: 127.0.0.1 (localhost) and PORT: 8081.
This is the error that occur:
I've reinstall nodeJs, npm and clean caches, but nothing It doesn't work. How to solve this error?

Related

Expo start shows "Starting Metro Bundler on port" forever

I am working on react native project.
It worked well before I reinstall computer OS.
Now if I run expo start it just show this.
Starting Metro Bundler on port 19001.
This takes forever.
If I run android emulator here, then this error appears.
Couldn't start project on Android: could not install *smartsocket* listener:
cannot bind to 127.0.0.1:5037: Only one usage of each socket address
(protocol/network address/port) is normally permitted. (10048)
could not read ok from ADB Server
* failed to start daemon *
error: cannot connect to daemon
What's wrong here? I am using Genymotion simulator.
I solved this.
I just set path environment to genymotion adb tool directory.
C:\Program Files\Genymobile\Genymotion\tools
And now it works well.
Thanks.

React native stuck at loading from localhost : 8081 on physical device using USB debugger

When I run react-native run-android it builds successfully and there after
Mobile screen shows nothing more than loading from local host : 8081
I have tried adb reverse tcp:8081 tcp:8081
Start by closing the App on your phone and clearing phone memory.
Close metro bundler on your PC.
Then clear npm cache as follows: npm cache clean --force
Then clean up gradle as follows:
Change into android directory in your project folder: cd android
To clean clean gradle simply run: ./gradlew clean
cd .. back into your project's root directory.
Build your app again using whichever method suits you. My preferred method for RN apps without expo on a windows machine is as follows:
npx react-native run-android
Try either of these ways to fix it:
Try to Open Developer menu by press Ctrl + M in emulator and choose the Setting port, then input the value localhost:8081.
Try to connect the other wifi, then run 'adb reverse tcp:8081 tcp:8081'
Try to change the URL on chrome to http://localhost:8081/debugger-ui/
Cheer!
Samsung DeX!
Samsung DeX runs in the background to discover device connections, it uses port 8081. In my case, it interfered with Metro and adb reverse. Exiting the system tray app fixed the entire issue.
For some reason it was a watchman issue. I remember installing watchman a few days before and it was causing the issue. I uninstalled watchman and it worked.
Uninstalling watchman made it work for me.

unable to connect with remote debugger unexpected end of stream on connection issue in react-native(android) in linux

When I am trying to connect to remote debugger it shows following error.
react version: 16.3.1,
react-native version : 0.55.2
tried with adb reverse tcp:8081 tcp:8081 and react-native start,but when I select the debug window still showing the above error.
Try to add your ip-address:8081 in Dev setting ==> debug server host and port for device...

Could not connect to development server on android emulator and on real device

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!
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.

Why I am not able to run react-native application on my android device?

I am getting this error when I try to run react-native application on my device.
Steps I did:
react-native init SampleApp
cd SampleApp
react-native run-android
react-native start
PS: On first attempt I did successfully run react-native app. Now I am getting this error. I searched a lot but couldn't find solution yet.
Normally, running react-native run-android will open up another command prompt to start the React Packager.
If the packager is somehow not started properly, you can try the following steps:
Run react-native start first to start the packager server manually.
Run react-native run-android which it will detect the packager is running and proceed with deploying the application into the device/emulator.
First, you mus open the react-native local packet server:
react-native start or npm start.
If there is still a problem, may be:
The IP address might be wrong.
Phone cannot access the IP address
Shake your devices show Menu(or click your devices Menu), click the last item dev config setup your computer ip, like 192.168.*.*:8081
The reason is that another application takes port 8081, which is needed for running Metro Bundler. After doing some research, I found out someone does "react-native start" to start the bundler before running "react-native run-ios/android". Running "react-native run-ios" is successful when I previously started the Bundler. After running "react-native run-android", the app can be viewed. However, after could click R to reload the app, it shows 404.
Make sure your port 8081 is not taken by another app. If so, every time when we type "react-native run-ios/android", the Bundler can be automatically started.
When the app is loaded, the window of Bundler should have a progress bar showing the detail of loading the bundle file under ios/android.
BUNDLE [android, dev] ./index.js ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100.0% (481/481), done.