How to change the default JS Server port in Android Application from 8081 to something else

1k views Asked by At

On my system another application is using 8081 port. I am running below command to start react-native app on 9988

react-native start --port 9988

However when I run android, app is still listening at 8081 port

react-naive run-android

I managed to get it running by using adb reverse command for my Physical device

adb -s <deviceid> tcp:8081 tcp:9988

I have to do this every time when I am running android on my Physical Device. For emulator it is still not working even after using adb reverse.

Is there config which I can change to default 9988 port

2

There are 2 answers

0
FMCorz On

Yes, shake your device and edit the development settings. If I remember correctly you must specify the IP followed by the port.

127.0.0.1:9988
0
eightyfive On
  1. Access the in-app developer menu – TLDR: adb shell input keyevent 82
  2. Dev settings > Debug server host & port for device (Under "Debugging" section)
  3. Enter localhost:9988
  4. react-native run-android --port 9988