Replacing the string localhost with 10.0.2.2 resolved it for me, since I was running the code in the Android emulator, which is running in a VM. It’s essentially a duplicate of this question.
Replacing the string localhost with 10.0.2.2 resolved it for me, since I was running the code in the Android emulator, which is running in a VM. It’s essentially a duplicate of this question.