I had the same issue with MQTT publisher from an android device. While referring to tcp://localhost:1883 from an android emulator, I had to use http://10.0.2.2:1883 since emulator runs on its own VM and localhost would be emulators own loopback address.