Skip to content
Advertisement

What should be my port number if I am using php database locally in my pc and using that api in flutter mobile application using physical mobile

I am currently fetching api from php database(Served locally in my pc) and sending get/post request from flutter mobile application using url = “http://10.0.2.2:8000/api/login” , here I used port number 10.0.2.2 because I am using virtual emulator and it works fine. My question is what should be my port number if I am using physical mobile device to run flutter mobile application(Not virtual emulator). How can I get that port number?

Advertisement

Answer

Try this

http://0.0.0.0:8000/api/login

The 10.0.2.2 host is how you access your localhost from the emulator. But for physical devices its 0.0.0.0

You might also need to run the below command after connecting your device. (ADB tools must be installed)

adb reverse tcp:8000 tcp:8000

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement