Search code examples
android-emulatorlocalhosthttpconnectionandroidhttpclient

How do you connect localhost in the Android emulator?


I have made a php script inside localhost and I am connecting that with httpClient but I am getting a problem.

Please tell me how can I connect to a php file at localhost from the emulator?


Solution

  • Thanks, @lampShaded for your answer.

    In your API/URL directly use http://10.0.2.2:[your port]/ and under emulator setting add the proxy address as 10.0.2.2 with the port number. For more, you can visit: https://developer.android.com/studio/run/emulator-networking.html

    enter image description here