Are you trying to run this via an emulator or on the device?
Also are you able to access localhost from the emulator or device?
I am taking a guess here but I'm thinking that your device cant reach localhost because its an internal server not broadcasting on port 80, even if it was you would not be able to connect via localhost, if your test server is on local host and open for web traffic then try connecting to the IP I would assume this would work if its open to the net.