'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



Solution 1:[1]

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:

  1. Change into android directory in your project folder: cd android

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

Solution 2:[2]

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!

Solution 3:[3]

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.

Solution 4:[4]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 andromeda
Solution 2
Solution 3 Mordechai
Solution 4 Binit