To test an MQTT broker from a phone, the fastest route needs no app at all: open the online MQTT client in Chrome on Android or Safari on iOS, connect over secure WebSockets (wss), subscribe and publish. For anything deeper — raw TCP on 1883, TLS on 8883, background behaviour — use a native MQTT app or a terminal on the device. This guide covers each approach and the network traps that only show up on mobile.
Why test from the phone at all?
Your laptop on office Wi-Fi is not where your users are. A mobile test answers questions a desktop test can't:
- Does the broker accept connections from cellular networks, not just from your office IP?
- Do carrier NAT and idle timeouts kill a quiet connection after a few minutes?
- Does your app's connection survive screen lock, app switching and network handover (Wi-Fi → 4G/5G)?
- Do certificates validate on the phone's trust store, which can differ from your desktop's?
Option 1 — The browser, over WSS
Mobile browsers support WebSockets, so MQTT over WebSockets works exactly like on desktop.
- On the phone, open testmqtt.com/client.
- Keep the protocol on WSS. For your own broker, choose Custom broker… and enter host
broker.connectmq.com, port8084, pathmqttand your test user's credentials. - Subscribe to a unique topic such as
testmqtt/phone-4c21/#and publish totestmqtt/phone-4c21/hello.
To avoid typing on a small keyboard, build the link on your laptop and open it on the phone (send it to yourself or turn it into a QR code):
https://testmqtt.com/client?url=wss://broker.connectmq.com:8084/mqtt&topic=testmqtt/phone-4c21/%23Then publish from your laptop and watch the phone receive it — that proves the full path from a desktop client through the broker to a mobile network:
mosquitto_pub -h broker.connectmq.com -p 1883 \
-t testmqtt/phone-4c21/hello -m "from laptop" -q 1Switch the phone from Wi-Fi to mobile data and repeat. If it works on one and not the other, you have a network problem, not a broker problem. The step-by-step desktop version is in test an MQTT broker from your browser.
Option 2 — Native MQTT apps
Native apps open real TCP and TLS sockets, so they test the same ports your devices use. Both app stores offer several general-purpose MQTT clients and dashboard apps — on Android, apps such as MyMQTT, MQTT Dash and IoT MQTT Panel; on iOS, apps such as MQTTool and IoT MQTT Panel. Availability and features change, so check the store listing, and prefer apps that let you:
| Capability | Why it matters for testing |
|---|---|
| TCP and TLS (8883) | Test the port your devices actually use |
| Custom CA / certificate options | Private CAs and client certificates |
| Username / password | Authenticated brokers and ACL checks |
| Choice of MQTT 3.1.1 / 5 | Match your device firmware |
| Subscribe with wildcards | Watch a whole device subtree |
| Retain and QoS options | Reproduce real device behaviour |
Use a dedicated test user with ACLs limited to test topics — mobile apps typically store credentials on the device.
Option 3 — A terminal on the phone
On Android, Termux gives you a Linux userland with the Mosquitto command-line clients:
pkg install mosquitto
mosquitto_sub -h broker.connectmq.com -p 1883 -t 'testmqtt/phone-4c21/#' -v &
mosquitto_pub -h broker.connectmq.com -p 1883 -t testmqtt/phone-4c21/hello -m "from termux"The same commands work with -p 8883 and --capath or --cafile for TLS (point it at a CA bundle you have on the device). On iOS, terminal apps are more limited; for scripting on iPhone a native app or the browser is usually simpler. Once the CLI works, everything from mosquitto_pub and mosquitto_sub examples applies on the phone too.
Testing your own app: emulators and simulators
When the app you are building can't connect, find out whether it's the code or the network:
- Android emulator:
localhostinside the emulator is the emulator itself. Use10.0.2.2to reach a broker running on your development machine. - iOS simulator: shares the Mac's network stack, so
localhostreaches a broker on the Mac. A physical iPhone does not — it needs the Mac's LAN IP. - Physical devices: the broker must listen on the LAN interface, not just
127.0.0.1(Mosquitto 2.x with no listener configured is local-only), and the host firewall must allow the port.
Platform rules can also block plain-text connections in your app. Android's network security configuration blocks cleartext traffic by default for HTTP-based stacks, which affects ws://; iOS App Transport Security applies to URLSession-based connections, including WebSockets. Use wss:// or TLS (8883) rather than adding exceptions. Library-specific setup lives in MQTT on Android with Kotlin and MQTT on iOS with Swift.
Mobile network traps
| Symptom | Likely cause | What to try |
|---|---|---|
| Works on Wi-Fi, times out on mobile data | Network restricts ports 1883/8883 | Test WSS on 443 if your broker offers it; check with the carrier/MDM |
| Connection drops after a few quiet minutes | Carrier NAT idle timeout | Keep-alive below the timeout (e.g. 30–60 s); see NAT timeouts |
| Disconnects whenever the screen locks | OS suspends the app | Expected; design for reconnect + persistent sessions |
| Burst of reconnects when switching networks | IP address changes on handover | Clean reconnect with backoff, same client ID |
Connection refused from a phone only | Broker bound to localhost or firewall rule | Listen on 0.0.0.0, open the port, test with nc from another machine |
| Certificate error on the phone, fine on desktop | Missing intermediate or private CA | Serve the full chain; install the CA on test devices |
For realistic flaky-network tests in the lab, see testing MQTT under cellular network conditions.
A five-minute mobile test plan
- Phone browser on Wi-Fi: connect over WSS, subscribe, publish, receive.
- Same test on mobile data.
- Publish from the laptop, receive on the phone (and the other way round).
- Native app or Termux: repeat on TCP 1883 and TLS 8883 with your real credentials.
- Leave a subscription idle for ten minutes; check whether it survives.
- Lock the screen, switch networks, unlock: confirm your app reconnects and resubscribes.
Testing from a phone takes minutes and catches problems no desktop test will: blocked ports on mobile data, NAT timeouts, sleeping apps and certificate chains that only fail on device trust stores. Start in the mobile browser over WSS, then move to a native client for the ports and behaviour your app depends on.
Frequently asked questions
What is the quickest way to test an MQTT broker from a phone?
Open an online MQTT client such as testmqtt.com/client in the phone's browser and connect over secure WebSockets (wss, often port 8084 or 443). It works the same in Chrome on Android and Safari on iOS and needs no app install.
Why can my phone not reach the MQTT broker running on my laptop?
localhost on the phone means the phone itself. Use the laptop's LAN IP address, make sure both are on the same network, that the broker listens on all interfaces rather than only 127.0.0.1, and that the laptop's firewall allows the port.
Why does MQTT work on Wi-Fi but not on mobile data?
Some mobile and guest networks restrict non-web ports such as 1883 and 8883, and carrier NAT can drop idle connections quickly. Test port 443 or WebSockets over 443 if available, and use a keep-alive shorter than the network's idle timeout.

