I'm using port 8088 instead of 8081 for my Android emulator (using these instructions), running on Windows 10.
The React Native Debugger is now throwing a ERR_CONNECTION_RESET error, which I suspect is because it's trying to connect to port 8081 (photo below).
How can I set the Debugger to use port 8088?
Note: I cannot use port 8081 because my school requires McAfee antivirus which uses the port. I promise, I wish I could just use 8081
Edit: Added emulator error
UPDATE
It appears that this is a known issue. Luckily, there is a pull request out to fix it.
In the meantime, I ended up stopping the program that was on port 8081 using Windows Services (search for 'services' in the Windows 10 search bar).
This issue is fixed in react-native 0.42 and above.
Related
I'm trying to run an app inside my Android emulator and on my Iphone using Expo and Create React Native App.
I' ve ran the following commands to do this.
create-react-native-app MyFirstApp
npm run android
After doing the run command the app runs in the emulator with the following error:
Something went wrong! Could not load *ip*. Network response timed out.
Uncaught error: java.net.SocketTimeoutException: connect timed out.
The same thing happens when I scan the QR code on my Iphone and I can't reach the ip in my web browser.
I've found the following fixes on internet but nothing seems to work:
Add port 19000 to the inbound rules in Windows Firewall
Update Java and npm
npm start instead of npm run android
Edit:
I installed Expo XDE to start the server. It works fine when I use a tunnel but that option is extremely slow when reloading changes. It still doesn't work with localhost or LAN. Is it possible that I have to use something like port forwarding to open this port on my router?
Also: When I typ: localhost:19000 in Google Chrome I get some Json returned. But this doesn't work when I'm in Expo!
Fixed the problem! I just found the following solution:
Go to cmd and type ipconfig
get the ip4 adress of the virtual machine and copy it.
Than go to computer > properties > advanced system settings > environment variables and add the following system variable: REACT_NATIVE_PACKAGER_HOSTNAME
As the value for the variable I had to paste the ip4 of the virtual machine.
I had the same problem. My issue was that VirtualBox had installed a couple of virtual ethernet adapters and NPM was choosing one of those. After disabling those in Control Panel > All Control Panel Items > Network Connections, the Expo app connected as expected.
Windows firewall blocks the request. You can define two inbound rules for Port 19000 and 19001
You can configure the port by defining a .exprc file containing:
{
"manifestPort": 8000
}
I had same issue. I disable all other network adapter and left WIFI adapter enable.
secondly you can also change the priority of adapter it also gonna work
I'm using Jenkins for continous integration on an android emulator to run instrumentation tests with the espresso framework. Unfortunately the server is not able to connect to the emulator. I have a master instance which delegates the push events from GitHub to the slave instance where the android sdk is installed. I installed the android-emulator-plugin and configured it like described. At first the Jenkins starts the emulator, but it cannot connect to it afterwards. This is the result:
I also cannot connect to the emulator when I'm on the slave machine. But if I use 127.0.0.1 instead of localhost the adb tool can connect to the emulator:
Is it possible to use 127.0.0.1 instead of localhost with the android-emulator-plugin? I already specified the enviorment variables $ANDROID_AVD_DEVICE and $ANDROID_SERIAL with no result. Any ideas?
I was fighting with it whole day. Just try to comment ipv6 in your /etc/hosts.
I fixed the problem by myself. I have checked out a fork on GitHub, which uses 127.0.0.1 instead of localhost. This did work for connecting to the emulator but not for running the instrumentation tests. I do not use Jenkins plugins for the connection anymore. I make the build with a shell script which contains all commands to start the AVD and the gradle tasks. Works fine for me. But thank you for the advice. Maybe I will try to comment ipv6 aswell, if I have the time to work on the Jenkins.
I used the react-native Android demo project AwesomeProject and within the project I executed:
react-native start
In a second terminal:
react-native run-android
To start webserver and install the Android APK. The default webserver configuration is localhost:8081, how can I modify the webserver port, and how do I update recording of the IP & Port in Android project.
Edit:
I just found out that can modify ip address in Android debug setting, it seems "getDebugServerHost" is a private API, does Facebook provide any API to change ip&port?
As OP commented on MossP's answer, this can now be achieved using the debug_http_host shared preference (see this issue).
So, if you wanted to use, say, port 8082, you could add an onCreate method to your MainActivity.java file, which might look something like this:
#Override
protected void onCreate(Bundle state){
super.onCreate(state);
SharedPreferences preferences =
PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
preferences.edit().putString("debug_http_host", "localhost:8082").apply();
}
Of course not forgetting to import android.content.SharedPreferences, android.os.Bundle, and android.preference.PreferenceManager.
This would make your app try to access the packager at the desired port instead of 8081.
Then you'd just make sure to start the packager with --port 8082 (as described here), and you should be all set.
(Unless you happen to be using Nuclide, which is a whole other story).
Note that up until React Native 0.46, this would only allow one to run the app successfully, but still didn't make it possible to actually attach a debugger on a non-standard port. As of React Native 0.46, attaching a debugger should also work.
Update: See Tomty's answer for the current recommended way to do this in 2019.
Unfortunately, the port is currently (2015/09/23) hardcoded. I believe this will be changed in time as it already has an Issue raised from a high level contributor to the project.
https://github.com/facebook/react-native/issues/2704
There is a small work around for this. Anyone running this on a physical device(or even otherwise) can restart their adb session using a different port.
eg.
react-native start --port=1234
On a different cmd/terminal window.
react-native run-android
After which I am greeted by these messages.
BUILD SUCCESSFUL
Total time: 22.589 secs
Running C:\SDK/platform-tools/adb -s VY0025160560725694 reverse tcp:8081
tcp:8081
This runs it on default reverse port of 8081, which is blocked by McAfee.
Work around:
adb reverse tcp:8081 tcp:1234
Try it out. It works for me.
Note: You may have to kill and re-open the app.
Currently I am unable to provide an answer for an emulated device since I do not have one installed on my system. But the symantics should be similar.
Note: This may break automatic code updates using watchman.
As stated in https://facebook.github.io/react-native/docs/debugging.html#accessing-the-in-app-developer-menu,
You can access the developer menu by shaking your device or by
selecting "Shake Gesture" inside the Hardware menu in the iOS
Simulator. You can also use the ⌘D keyboard shortcut when your app is
running in the iOS Simulator, or ⌘M when running in an Android
emulator. Alternatively for Android, you can run the command adb shell
input keyevent 82 to open the dev menu (82 being the Menu key code).
So on iOS device shake it, on iOS emulator press control D, on Android emulator control M, on Android device do adb shell input keyevent 82
Then in the menu that opens, go to Dev Settings, debug server & host port for device, and edit the IP and port.
ps: will only work for non production
On Mac :
go To Wifi
Open network preferences
Wi-Fi is connected to {wifi name} and has the IP address {xxx.xxx.x.x}.
Get your ip address .
Go to application on devices
go to Dev Setting
Tap to Debug server host & port for device
Fill your IP address and port is 8081 (example ipaddress:8081) .
This is an extension of Tomty's answer. Check out an example project here:
npm i #nick-bull/react-native-debug-address
# DEBUG_HOST=127.0.0.1:8081 npx react-native start --port 8081
# or, equivalently
DEBUG_PORT=8081 npx react-native start --port 8081
npx react-native run-android --port 8081
Error running Android Debugger (8600):
Unable to open debugger port (localhost:8600):
java.net.SocketException "Connection reset"
I was able to fix this with these commands:
adb kill-server
adb start-server
Try Restarting ANDROID STUDIO (Worked for me)
In my case, there was another service running on my laptop(Windows) that was using the port 8600. I opened Task Manager and stopped the service. Now, I could debug my application normally without the above error.
I solve the problem by checking my localhost.
Making sure 127.0.0.1 localhost.
For me this problem started when i upgraded my Android Studio to new version.
Please go to options menu Build and choose Clean Project.
That is it project started to run again and error was gone.
I tried other answers (e.g. restarting Android Studio) but they didn't solve this for me.
I had accidentally selected MTP (Media Transfer Protocol) in my Developer Options/USB Configuration. It started working once I set it to PTP (Picture Transfer Protocol).
EDIT: On reflection it's probably just that I changed the protocol because I've had the same issue since while on PTP. Hence I'm suggesting that the real answer is to change the protocol on the phone and, if you might need it, don't forget to change it back.
It could be that you need to wait for your code to stop compiling before you attached the debugger. I had a similar error and all I needed was patience.
If you using WiFi debug:
Exit ANDROID STUDIO
adb kill-server && adb start-server
adb tcpip 5555
adb connect [your wi-fi IP]:5555
Start ANDROID STUDIO
I did spent quite an amount of time by trying below things:
Re-installing old(3.6.3) and new(4.0.1) Android studio and Android SDK's
checking all the security things in newly installed Mac OS Catalina
Checking all the developer options in my physical android device and AVD
And all the things mentioned in this post as well: https://medium.com/returntrue/android-studio-cant-bind-to-local-8600-for-debugger-%E3%81%A7%E3%83%87%E3%83%90%E3%83%83%E3%82%AC%E3%83%BC%E3%81%8C%E6%B0%B8%E4%B9%85%E3%81%AB%E8%B5%B7%E5%8B%95%E3%81%97%E3%81%AA%E3%81%84%E3%81%A8%E3%81%8D%E3%81%AB%E3%82%84%E3%81%A3%E3%81%9F%E3%81%93%E3%81%A8-8f5dd9c8ca70
Finally a small change in my /etc/host file resolved this issue. I commented from 0.0.0.0 and ::1 for localhost local DNS entries and enabled only 127.0.0.1
I am trying to debug the android source using Eclipse by following the instructions found at:
http://source.android.com/using-eclipse
I have downloaded the source, and gotten it to build. I follow the directions in the link above and everything is fine until I run the ddms command. At this point, if Eclipse is running I get the error 'Could not open Selected VM debug port (8700)'. If I close Eclipse, then ddms runs with no problem, and I can the the processes on the emulator. However, if I now open Eclipse, I get the same error.
In any case, no matter what I do, if I attempt to remote debug, it always fails with 'Failed to connect to remote VM'.
Any ideas?
Thanks
It looks like you have two problems:
You are trying to run DDMS twice. You do not need to run the free standing version of DDMS since there is version of it integrated in Eclipse as part of the Android plug-in. If you change to the DDMS perspective in Eclipse, I'm sure you will find that all the same features are available.
You have not told DDMS which VM you want to debug at localhost:8700. Before you attempt to establish your remote debug connection, you must go to the DDMS perspective and click on the system_process (or whatever process you want to debug).
The Windows Host file that is messed up is at C:\WINDOWS\system32\drivers\etc, and it should contain this line:
127.0.0.1 localhost
If that doesn't work, then try making the following changes in Eclipse.
Under Window -> Preferences -> Android -> DDMS:
Set Base local debugger port to "8601"
Check the box that says "Use ADBHOST" and the value should be 127.0.0.1
I solved it by ending the process "adb.exe" through Task Manager and then reloading the SDK through Windows->Preference..I am running Eclipse Indigo on Win 7 64-bit.
I was having that problem too (Windows 7), even though my /Windows/system32/drivers/etc/hosts file already had 127.0.0.1 localhost in it.
I tried changing the ADBHOST info & port in the eclipse Preferences, but that didn't do anything.
netstat -b shows '127.0.0.1' as the source address for adb and the emulator, but always lists my machine host name as the 'foreign address.' On a hunch, I tried debugging with my machine not connected to any network (no WiFi, nothing plugged in)... and it worked! (DDMS was able to connect to the VM on the emulated device and I was able to debug just fine.)
I think that messages sent by DDMS &/or adb are not staying on my local machine (they're getting sent to my local router). (It's just a guess; I don't know how to conclusively test that.) IOW, loopback wasn't working as it should.
Since I already had 127.0.0.1 in my localhosts, I added the local subnet address of my machine into my hosts file, guessing that DDMS/adb might be using that address (vs. 127.0.0.1). That seemed to solve the problem for me.
So now my hosts file has these lines:
127.0.0.1 localhost
::1 localhost
192.168.1.102 localhost
(The local IPv4 address for my machine is 192.168.1.102 . You can check yours with the ipconfig command.)
(I came across some webpages that how to set up a virtual network adapater for Windows that handles loopback, e.g. Setting up a Microsoft Loopback Adapater (from Oracle Distilled), but haven't had time to take that in and see if that's a viable solution to all of this, too.)
I solved it by opening the windows Task manager and closing the process "adb.exe". Then close eclipse and reopen it. It will start properly without any error.
This is for reference. But I guess this might match your case.
Port 8700 is very special port for ddms; there's no way to change the port.
Port 8700 is used for aggregating the packet from every Dalvik VM.
There will be two cases;
case 1) If you set "Base local debugger port"(in Eclipse ddms preference dialog) to 8700, then you'll see error - "Can't bind to local 8700 for debugger", everytime ddms initiated. But no problem, because if ddms couldn't bind 8700 to the first VM, then will be connected to 8701, and then 8702 and so on.
case 2) Even if you set "Base local debugger port"(in Eclipse ddms preference dialog) to 8600, you may see error - "Can't bind to local 8700 for debugger", in some cases. Because, if your device have more than or equal to 100 dalvik VMs, port assigning to each VM starting from port 8600 may reach to 8700 port. But, no problem occurs same as in case 1).
So, if you really don't want to see the error, you have to set the "Base local debugger port"in Eclipse ddms preference dialog to 8701 or above.
Stand-alone ddms or android monitor uses different setting file from Eclipse, so it may not make this kind of problems.
~
Had the same problem, different port numbers in the console output (where I launch ddms) caught my attention
Then from the documentation, I learned that 8600 is the default base port number. Every new process uses the next available port (8601,8602,...). In addition, 8700 is the default active port number (indicating the currently selected process in the dbms)
Here are the steps to debugging Android source+applications
Run emulator
Run ddms
Open Eclipse (It may complain about being unable to connect to 8600. This is because, when Eclipse starts up and if you have Android plugin, it boots up ddms. Since we already have a ddms connected to the device, trying to connect for a second time won't work)
In the ddms, pick a thread you want to debug (when you highlight it, it will show you the ports that it is using as well as 8700 (e.g. "8649 / 8700"). This means you can use both ports to connect to this process
From eclipse, using the remote debugging configuration, connect to any process you wish (easiest is to highlight the process from within ddms and then connect to 8700)
This type problem occurs when you are using another VM with the same port number. As an example you are using Android SDk full bundle which you have downloaded from the android developer website. Now you want to use Eclipse and plugged in ADT, SDK. There is a high probability to happen this type of error. It happened to me. To overcome this difficulties you can do :
Window-Preferences-Android- Choose DDMS- Change base local debugger port(use 8601 instead of 8600).
It can work. Thanks
I done it by restarting my computer
Just for completeness: (on win 7/Vista) not only you have to make sure line
127.0.0.1 localhost
is present in
C:\WINDOWS\system32\drivers\etc
you also need to comment out all your other local virtual hosts resolving from 127.0.0.1. This is most probably the case if you're developing web stuff on the same machine and set it up earlier for different host names looping back to local.
I solved the problem by ONLY close android studio so the eclipse can get ddms
When I execute monitor in $ANDROID_HOME/tools/monitor on Ubuntu 16.04, it shows
Could not open Selected VM debug port (8700). Make sure you do not
have another instance of DDMS or of the eclipse plugin running. If
it's being used by something else, choose a new port number in the
preferences.
I tried to do the following:
Under Window -> Preferences -> Android -> DDMS:
Set Base local debugger port to "8601" Check the box that says "Use
ADBHOST" and the value should be 127.0.0.1
But it still pops up the dialog.
Then I did the following:
gongzelong#gongzelong:~$ netstat -apn |grep 8700
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 127.0.0.1:8700 0.0.0.0:* LISTEN 5044/java
gongzelong#gongzelong:~$ kill -9 5044
gongzelong#gongzelong:~$ monitor
By doing this, it solved my problem.
Do not know why, but it works for me.