VPS for MQTT: Why IoT SIM Cards and a Cloud Broker Are a Natural Pairing
From smart meters to remote machinery, millions of UK IoT devices already run on M2M SIM cards. Here is what happens to the data once it leaves the device – and how to own that pipeline yourself.
The Problem: What Do You Do With Your SIM Card Data?
You have ordered IoT SIM cards or M2M SIM cards. They are provisioned, they have a fixed IP or APN, and your devices – sensors, routers, remote PLCs, EV chargers, vending machines – are reporting data on a schedule. Now what?
This is the moment most deployments hit a fork in the road. The data needs to land somewhere. It needs to be stored, processed, and ideally visualised or forwarded to a business system. The two most common routes are:
- Use a managed IoT platform – something like ThingsBoard, HiveMQ Cloud, or AWS IoT Core. You point your devices at their broker endpoint, and the platform handles everything above the network layer.
- Run your own MQTT broker on a VPS – you deploy Mosquitto, EMQX, or VerneMQ on a cloud server, and your SIM-connected devices report directly to that IP. You own the stack.
Both are legitimate. But for teams with more than a handful of devices, a preference for data sovereignty, or a need to integrate with unusual backends, the self-hosted VPS route offers something managed platforms cannot: total control at a fixed cost.
Why MQTT Is the Natural Protocol for IoT SIM Card Deployments
MQTT was designed by IBM in the late 1990s for SCADA telemetry over satellite links – low bandwidth, unreliable connections, battery-constrained endpoints. It maps almost perfectly onto modern cellular IoT deployments.
Minimal overhead on metered data
A typical MQTT CONNECT packet is around 14 bytes. A PUBLISH with a JSON payload might be 80-300 bytes. Compare that to HTTP REST, where headers alone often run to 500+ bytes per request. On a metered M2M SIM with a 1 MB or 5 MB monthly allowance, this difference is meaningful – especially across hundreds of devices publishing every 30 seconds.
Persistent sessions over intermittent cellular
Cellular connections drop. Devices move in and out of coverage. MQTT’s clean session flag, QoS levels, and Last Will and Testament (LWT) feature are built for exactly this reality. A device can reconnect and pick up any messages it missed while offline, without the application layer needing to manage retry logic.
QoS levels matched to use case
- QoS 0 – fire and forget. Good for non-critical telemetry like ambient temperature readings.
- QoS 1 – at least once delivery. Suitable for alarm states where missing a message is unacceptable.
- QoS 2 – exactly once. Used where duplicate processing would cause a real problem, such as billing or command execution.
Fixed IP SIMs and direct broker access
If your IoT SIM cards come with a fixed IP address or are on a private APN, your devices can publish directly to your VPS broker IP without any NAT traversal or port-forwarding issues. This is one of the cleanest possible architectures for a cellular IoT deployment.
Managed Platform vs Self-Hosted VPS
| Factor | Managed Platform | Self-Hosted VPS |
|---|---|---|
| Setup time | Minutes | Hours (one-off) |
| Cost at 100 devices | $50-$300/month | ~£6-£20/month |
| Data sovereignty | Vendor holds data | You hold all data |
| UK GDPR | Depends on vendor DPA | Full control |
| Uptime | Vendor managed | Your responsibility |
| Custom integrations | Platform APIs only | Unlimited |
| Device limit | Tiered pricing | No artificial limit |
| Vendor lock-in | High | None |
Not ready to self-host yet?
ThingsBoard offers both a free self-hosted Community Edition and a fully managed cloud option. It handles dashboards, device management, rule chains, and multi-tenant access – meaning you can start managed and migrate later if you want to bring everything in-house.
Explore ThingsBoardMQTT Broker Options: Deploy in Minutes with Docker
If you have a VPS with Docker installed, any of the following brokers can be running in under ten minutes. Each serves a different point on the spectrum from simple to enterprise-grade.
The most widely deployed MQTT broker in the world. Lightweight, battle-tested, and easy to configure. Ideal for smaller deployments or as the transport layer beneath a larger stack.
docker pull eclipse-mosquittoHigh-performance broker built for scale. The open-source edition handles millions of connections and includes a web dashboard out of the box.
docker pull emqx/emqxBuilt on the Erlang OTP stack. Designed for horizontal scaling and high-availability clustering. Supports plug-ins for authentication and data persistence.
docker pull vernemq/vernemqA Java-based broker with strong enterprise pedigree, excellent documentation, and good plugin extension points.
docker pull hivemq/hivemq-ceNot a broker, but an indispensable companion. Connects your MQTT broker to databases, REST APIs, dashboards, and alert systems.
docker pull nodered/node-redThe standard open-source time-series visualisation stack. Node-RED or Telegraf writes MQTT data into InfluxDB; Grafana renders the dashboards.
docker pull grafana/grafanaFor a full breakdown – Docker Compose files, TLS certificate setup, Mosquitto ACL syntax, and Node-RED wiring – see the in-depth guide at iotvps.co.uk: VPS for MQTT.
Security: The Part People Skip
Running your own MQTT broker means full control – and full responsibility. The internet is actively scanned for open MQTT ports. An unprotected broker on port 1883 with no authentication will receive connection attempts within hours of going live.
Production security checklist
- Disable anonymous access. Set
allow_anonymous falsein Mosquitto config. Every client must authenticate. - Enable TLS on port 8883. Use Let’s Encrypt for a public hostname, or a self-signed CA for private APN deployments. Never run plain MQTT on port 1883 in production.
- Use per-device client certificates. Each M2M SIM or device gets its own certificate. Revoke individually without affecting the fleet.
- Implement ACLs per device. A temperature sensor should only publish to its own topic – never subscribe to others or send commands.
- Lock down UFW. Allow port 8883 inbound, port 22 from your IP only, port 443 if running a dashboard. Close everything else.
- Keep software patched. Set up unattended-upgrades on Ubuntu. Schedule regular manual updates for the broker itself.
- Configure Last Will and Testament (LWT). The broker publishes an offline status if a device disconnects unexpectedly – useful for alerting.
- Monitor failed authentication attempts. A spike often indicates a scanning bot or misconfigured device.
- Rate-limit connections. EMQX and HiveMQ support this. Protects the broker if a device enters a reconnect loop.
Remote Access to Field Equipment Over a SIM Connection
MQTT is not the only thing your VPS can do once your IoT SIM cards are on the network. A VPS with a fixed public IP creates an accessible endpoint that field devices can connect back to – enabling secure remote access to equipment that would otherwise be unreachable behind carrier-grade NAT.
Pattern 1: SSH reverse tunnel
Your remote device opens an outbound SSH connection to your VPS and creates a reverse tunnel. You can then SSH into the device from the VPS without knowing the device’s IP or punching through the cellular NAT. Works over any IoT SIM with outbound TCP access.
Pattern 2: WireGuard VPN over cellular
Your VPS runs a WireGuard server. Each field device runs a WireGuard peer. The SIM card provides outbound connectivity; WireGuard provides an encrypted tunnel and a stable virtual IP for each device. Once established, you can reach any port on the remote device – web UI, serial-over-IP, Modbus TCP. Recommended for production deployments requiring reliable access to multiple devices.
Pattern 3: MQTT as a command channel
Your devices subscribe to a control topic alongside their publish topics. From a dashboard or API call on your VPS, you publish a command message. The device receives it, acts, and publishes a confirmation. No inbound ports on the device needed – it only ever makes outbound connections to the broker. The safest pattern for remote command execution over cellular.
| Pattern | Use Case | Inbound ports on device | Complexity |
|---|---|---|---|
| SSH reverse tunnel | Ad-hoc access, debugging, file transfer | None | Low |
| WireGuard VPN | Persistent access, web UI, Modbus TCP, SCADA | None (outbound only) | Medium |
| MQTT command channel | Remote config, firmware flag, OTA trigger | None | Low |
What VPS Spec Do You Need?
MQTT is extremely lightweight at the broker level. A four-core VPS with 4 GB RAM will comfortably handle thousands of concurrent connections. The bottleneck in most deployments is the time-series database and dashboard query load, not the broker itself.
A practical starting point for a self-hosted IoT stack with up to 500 devices publishing every minute:
- CPU: 2-4 vCPU
- RAM: 4-8 GB (InfluxDB is the memory consumer)
- Storage: 40-80 GB SSD (depends on retention period and payload size)
- Network: 1 Gbps port, unmetered or at least 1 TB/month
- Location: UK or EU data centre for UK GDPR compliance
LumaDock offers UK and EU VPS options that fit this profile at a price point that makes sense for IoT projects where the SIM contract is already the primary ongoing cost. View LumaDock VPS options.
Which IoT SIM Features Matter for MQTT?
- Fixed IP addressing. A static IP on your SIM means devices always appear at the same source address. Simplifies firewall rules, ACLs, and logging significantly.
- Private APN. Isolates your device traffic from the public internet at the network layer. Devices connect directly to your VPS through the MNO’s private network.
- Multi-network SIMs. For devices in locations with variable coverage, a multi-network or roaming IoT SIM ensures the device stays connected by switching to the strongest available network.
- LTE-M or NB-IoT. For devices transmitting small telemetry payloads over long periods, LTE-M and NB-IoT SIMs reduce power consumption. Both protocols support MQTT over TCP.
- Data pooling. Across a fleet, usage is uneven. Pool plans allow high-publishing devices to draw from the same allowance as low-volume sensors.
Ready to set up your MQTT broker on a VPS?
The full technical guide – covering Docker Compose configuration, TLS certificate setup, Mosquitto ACL syntax, Node-RED integration, and InfluxDB retention policies – is at iotvps.co.uk.
Read the Full VPS for MQTT GuideFrequently Asked Questions
Can I run an MQTT broker on a VPS using a standard IoT SIM card?
Yes. The MQTT broker runs on the VPS, not on the SIM card. Your IoT SIM-connected devices publish to the broker’s public IP address over TCP port 8883 (TLS). The SIM card simply provides the outbound internet connection for the field device.
Do I need a fixed IP SIM card to use MQTT?
Not strictly. You need a fixed IP on your VPS (the broker), which is standard. A fixed IP on the SIM card (the device) makes firewall rules and ACLs easier to manage, but it is optional if you are using per-device certificates for authentication instead.
How much data does an MQTT connection use monthly?
A sensor publishing a 200-byte payload every 60 seconds uses approximately 8-12 MB per month including keepalive traffic. Higher-frequency publishing or larger payloads scale linearly.
Is ThingsBoard MQTT-compatible?
Yes. ThingsBoard has a built-in MQTT broker. Devices publish to v1/devices/me/telemetry using an access token as the MQTT username. The Community Edition is free to self-host; the managed cloud version removes the infrastructure overhead.
Can I use MQTT over LTE-M or NB-IoT SIM cards?
Yes, with caveats. LTE-M supports standard TCP and therefore full MQTT including QoS 1 and 2. NB-IoT has higher latency and some operators restrict TCP session persistence – QoS 0 or QoS 1 with short keepalive intervals is recommended.
Is running my own MQTT broker UK GDPR compliant?
Running your own broker in a UK or EU data centre gives you direct control over where data is stored and processed. This is generally easier to document in a GDPR Article 30 record than a managed cloud service where data may transit multiple jurisdictions. You still need TLS, authentication, ACLs, and a clear data retention policy.
Leave a Reply