score:30

Accepted answer

Since your Android device has an IP of its own, you need to point the URL to your computers IP address instead of just localhost. For example fetch('http://192.168.0.2:3333/').

score:13

Use the reverse command of the Android Debug Bridge tool (adb):

adb reverse <remote> <local> - reverse socket connections.
                               reverse specs are one of:
                                 tcp:<port>
                                 localabstract:<unix domain socket name>
                                 localreserved:<unix domain socket name>
                                 localfilesystem:<unix domain socket name>

For example:

adb reverse tcp:3333 tcp:3333

This makes localhost:3333 accessible from your device. You can also use different ports. For example:

adb reverse tcp:8081 tcp:3333

This will redirect the device port 8081 to the local port 3333.


Related Query

More Query from same tag