[react-native]could not connect to development server on android

Clash Royale CLAN TAG#URR8PPP
[react-native]could not connect to development server on android
When I run "react-native run-android",it gives me error:"could not connect to development server...".
So how to fix the red error screen issue?Any suggestion is appreciated!
enter image description here
adb reverse
but you might have to go with facebook.github.io/react-native/docs/…
– goldylucks
Feb 6 '17 at 9:48
Run npm start on local machine to start the development server. I have faced same problem and It worked for me like magic
– ashraful
May 2 '17 at 11:57
7 Answers
7
From the Docs:
http://facebook.github.io/react-native/docs/running-on-device.html#method-2-connect-via-wi-fi
Method 2: Connect via Wi-Fi
You can also connect to the development server over Wi-Fi. You'll
first need to install the app on your device using a USB cable, but
once that has been done you can debug wirelessly by following these
instructions. You'll need your development machine's current IP
address before proceeding.
Open a terminal and type /sbin/ifconfig to find your machine's IP
address.
Yes,I use Wi-Fi and the mobile device and computer are on the same WIFI network.
– cityvoice
Feb 7 '17 at 1:25
did you follow these commands? any chance you can make a quick screencap and upload as a gif file?
– goldylucks
Feb 7 '17 at 6:36
ok man I am only trying to help ... can you try starting a fresh project with
react-native init myProject and see if you can connect? so we can eliminate the possibility of the problem being in your code.– goldylucks
Feb 7 '17 at 13:07
react-native init myProject
Sure! kindly upvote :) fur the future, whenever you are dealing with a new framework / tool, always check fresh installation if you encounter a problem. Will help you find the problem faster AND will save others' people time. good luck mate
– goldylucks
Feb 9 '17 at 7:56
@xerotolerant -- You can hit
adb shell input keyevent 82 on your command-prompt to open the developer-menu.– Saumik Bhattacharya
Sep 7 '17 at 18:42
adb shell input keyevent 82
f you are trying to debug app in your physical android device over wifi using a windows machine, then the device may not be able to access the port of your pc or laptop,
you have to make the port accessible. this involves two steps:
1.First create a rule in firewall. for doing this follow the following steps:
open run dialog
-type wf.msc
-click on inbound rules
-click new rule on right hand side
-select port from pop up menu and click next
-select tcp port and specific local ports and enter the port number like 8081(default)
-allow the connection
-select all in profile section
-give some appropriate name and description
-click finish
You are good to go, now try running react-native run-android.
This is most probably a firewall issue. If someone using ubuntu faces this issue , then you can use
sudo service iptables stop
to disable the firewall for the port to be accessible
and first of all I appreciate you for posting your doubt.
It's mainly because maybe your expo or the app in which you run your react native project may not be in the same local connected wifi or LAN.
Also, there is a chance that there is disturbance in your connection frequently due to which it loses its connectivity.
I too face this problem and I personally clear the cache and then restart again and boom it restarts perfectly.
I hope this works for you too!
To add to goldylucks's answer, you can use IP 192.168.0.10 if that is the IP of your PC running the React Native packager.
goldylucks
You may need to open your firewall as well.
In Ubuntu 18.04, you can get your IP by:
ip -c addr show
You will see your IP in there, something like: inet 192.168.0.10/24 brd 192.168.0.255 scope global dynamic noprefixroute enp0s25 (notice the 192.168.0.10 in my sample).
inet 192.168.0.10/24 brd 192.168.0.255 scope global dynamic noprefixroute enp0s25
Then, you could open port 8081 in your firewall, something like:
sudo ufw allow 8081
It will be using TCP, so make sure TCP is open on port 8081.
Then you can follow goldylucks's answer and goto Dev settings and enter 192.168.0.10:8081 or whatever IP you need.
Dev settings
192.168.0.10:8081
You can test it from the browser on your device. While the packager is running from your PC, navigate to http://192.168.0.10:8081 from your mobile device and make sure it works. It will show something like "Packager running". It will be clearly working or failing.
http://192.168.0.10:8081
Goldylock's answer excites me because it solves the issue very nicely if you are having problems with that error messages. It sucks to have to rebuild the app all the time or worse yet, delete the APK off your device and then build again.
As such, you should probably be using wifi as part of your dev strategy.
We faced this issue, In order to fix this, solution is dead simple is below.
Basically this error tells that your current build got failed due to reasons like Code issue or dependency issue.
Click here for more details
Basically this error tells that your current build got failed due to reasons like Code issue or dependency issue.
In order to fix this issue, solution is dead simple is below.
react-native run-android
react-native run-android
Please source this article: medium.com/error-healer/…
– mcranston18
Jul 6 at 13:21
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
did u look at stackoverflow.com/questions/38835931/…? he run
adb reversewith android 4.4.2– goldylucks
Feb 6 '17 at 9:46