Unable to make calls to Localhost using Flutter, random port being assigned to HTTP GET call

This should do it

adb reverse tcp:5000 tcp:5000

https://developer.android.com/studio/command-line/adb.html

Or use adb reverse --list to see what redirects are set up.


Günter's answer is correct, but one thing you need to keep in mind, that don't forget to change port number For example if your port is 3002 then use:

adb reverse tcp:3002 tcp:3002

Keep in mind that above mentioned command is redirecting your phone's port 3002 to your computer's port 3002.

If you want to redirect your phone's port 3000 to your computer's port 3002 then the command would look like

adb reverse tcp:3000 tcp:3002

More general answer is:

adb reverse tcp:<Your Phone's Port No.> tcp:<Your Computer's Port No>