Use 10.0.2.2
to access your actual machine.
As you've learned, when you use the emulator, localhost
(127.0.0.1
) refers to the device's own loopback service, not the one on your machine as you may expect.
You can use 10.0.2.2 to access your actual machine, it is an alias set up to help in development.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…