How to connect to my http://localhost web server from Android emulator
P粉450079266
2023-08-23 21:31:00
<p>How to connect to a localhost web server at <code>http://localhost</code> or <code>http://127.0.0.1</code> in the Android emulator page? < /p>
</p><p>I've tried this but the emulator still accepts my request just like a Google search for localhost, or worse it says it wasn't found when my webserver is up and running page. </p>
Use
10.0.2.2
as the default AVD and10.0.3.2
as genymotion.Localhost refers to the device the code is running on, in this case the emulator.
If you want to reference the computer running the Android emulator, use the IP address 10.0.2.2.
You can read more information here.