IMD SolutionComputing LibraryShop main store

Explainer

Does a local MQTT broker need a static IP address

Edge computing and IIoT Published 7 min read By IMD Solution engineering team

Short answer

No. A local MQTT broker needs a stable endpoint, not a static address specifically: point every client at a fixed IP or at a hostname that dynamic DNS keeps mapped to the broker's current address. After any address change, verify DNS resolution and an actual MQTT connect from each remote unit; VPN and firewall choices are a separate security decision.

On this page
  1. What the broker endpoint actually requires
  2. A static address: the simple case
  3. A fixed hostname with dynamic DNS
  4. How fast clients follow an address change
  5. What to verify after any address change
  6. VPN and firewalls: a separate decision
  7. The decision
  8. Questions asked

No. A local MQTT broker does not need a static IP address; it needs a stable endpoint. Every MQTT client stores one broker endpoint made of a scheme, a host and a port, and the host field works as well with a hostname that dynamic DNS keeps mapped to the broker's current address as with a fixed address. Pick one form for the whole fleet, point every remote unit at it, and after any address change verify both name resolution and a real MQTT connect from each unit. Whether you also put a VPN or a dedicated firewall in the path is a security design decision, and it does not change this answer.

What the broker endpoint actually requires #

An MQTT client treats its configured endpoint as a string: it hands the host part to its resolver, opens a TCP connection and speaks MQTT over it. Plain MQTT runs on TCP port 1883 and MQTT over TLS on 8883, and nothing in the protocol cares whether the host is a number or a name. The only real requirement is that the string every client stores keeps landing on the running broker from wherever that client sits — the plant LAN, a cellular link or a tunnel.

The local server just has to be an always-on computer on a network the clients can reach. For a cabinet-mounted broker box, a fanless mini PC is the usual host for that job.

A static address: the simple case #

Give the broker host a fixed address, either set on its interface or reserved for it on the DHCP server — for example 192.168.10.20 on a plant network. A fixed address takes DNS out of the failure path entirely: no record to update, no resolver cache to expire, no updater process to stop. After you edit a client's stored endpoint, the only check left is that the client completes a real connect.

Choose the fixed address when the server's place in the network is settled and every client reaches it over links you administer. Note the boundary: a private address is reachable only inside your own network, so cellular clients connecting straight over the internet need port forwarding or a tunnel in front of it. That is a reachability and security question, taken up below, not part of the addressing choice.

A fixed hostname with dynamic DNS #

Keep one name for the life of the service — mqtt.example.com as an example — and run a dynamic DNS updater on the broker host that posts the current address to that name's record. Two conditions make it work. First, the name must live in DNS the clients actually query: units on cellular modems resolve through their carrier's resolvers, so a name that exists only on the plant's internal DNS server will not resolve from the field. Publish the record publicly or in DNS reachable through the tunnel. Second, set the TTL short so cached answers stop being served soon after a change; the worked example below quantifies it.

Dynamic DNS beats a pinned address whenever the address can move on its own: a virtualized or containerized broker host, a planned hardware swap, a standby server waiting in failover. Those setups change the address without anyone editing a client, and the name absorbs the change.

TLS travels with the endpoint form. The server certificate must carry the name the clients dial, so a fleet that switches from an address to a name has to be checked — or reissued — against a certificate containing that name. The failure has a name of its own: MQTT TLS fails when the certificate lacks the broker DNS name. The trusted CA material and the TLS mode are part of the endpoint definition and move with it.

How control devices resolve hostnames, and where that resolution breaks, is its own subject; guide to DNS hostname resolution in industrial control systems goes deeper.

How fast clients follow an address change #

Treat one reported failure mode as a design input rather than a rule: public issue reports describe embedded MQTT clients that kept dialing the broker's old address after a dynamic DNS change because they resolved the name once and reused the answer until restart. Whether your client stack behaves that way is testable — force one address change on the bench and watch what it dials.

For planning, take example inputs: the updater posts a new address within its 60-second poll interval, the record's TTL is 60 seconds, and a client that loses the broker retries every 30 seconds. A client that resolved the name just before the change can hold the old cached answer for up to the TTL after the record updates, the record itself appears only after the updater's next poll, and the client's next attempt lands one retry interval later. Worst case for the last unit to catch up: 60 + 60 + 30 = 150 seconds, about two and a half minutes.

The total moves second for second with each term. Cutting the TTL to 30 s gives 60 + 30 + 30 = 120 s, and lengthening the retry interval adds its whole change to the same sum. The TTL is the term you control on the DNS side; the retry interval belongs to the client stack; a pinned address removes the window entirely. The arithmetic assumes resolvers honor the TTL you publish — a few recursive resolvers apply their own minimum — so measure one real change and keep the measured number.

What to verify after any address change #

A DNS lookup that returns the right address proves resolution, not communication. Run this sequence on every remote unit — not on one bench device — after the change:

  1. From a client-side network, a cellular link rather than the plant LAN, resolve the broker name and check the answer is the current address.
  2. Open a TCP connection to the broker port: 1883 plain or 8883 with TLS.
  3. Complete an MQTT connect with that unit's credentials and confirm the broker accepts them.
  4. Publish to a test topic and confirm the message arrives on a subscription at the broker.
  5. Power-cycle the unit and confirm it reconnects on its own; connect failing after power loss because the CA certificate is missing is a documented failure of exactly that step.

If the name fails while the address form works from the same unit, the fault is resolution, not the broker — the same pattern as an MQTT sink that stays offline until you use the broker IP address. On cellular gateways the same split shows up as publishing by IP while the hostname never resolves, which is what why an Ewon Flexy 205 publishes MQTT by IP but not hostname documents.

VPN and firewalls: a separate decision #

Nothing in the addressing choice obliges a VPN, and adding one does not remove the addressing requirement — a client behind a tunnel still resolves a name or dials an address. Keep the two questions apart. Addressing: one stable endpoint, by either route above. Security: a broker carrying plant data must never be reachable anonymously from the internet — do not forward a plaintext 1883 listener to the public side. If cellular clients must connect without a tunnel, TLS on 8883 with real authentication is the minimum, and a filtering firewall or VPN in front of the broker is the cleaner pattern. Which product fills that role follows from your network design, not from the endpoint choice; the guide to choosing a firewall VPN for an industrial remote access router walks through it.

The decision #

If the old cloud broker must keep serving while the local one comes up, bridge the two instead of repointing clients twice; how to bridge a local Mosquitto broker to a cloud broker shows the pattern. Otherwise:

Situation Endpoint choice What you accept
Fixed server on networks you administer Static address or DHCP reservation No DNS dependency; verify a real connect from each unit after any client edit
Address can move: virtualized host, container, hardware swap, standby server One fixed hostname, dynamic DNS updater, short TTL A bounded catch-up window of updater interval + TTL + retry, 150 s in the example above
Cloud broker still running during cutover Bridge cloud and local, repoint the fleet once Two brokers during the changeover; verify the bridge before repointing

For the migration itself: put the local server on a fixed address if its place in the network is settled; if its address can move, give it one name plus a dynamic DNS record and accept the bounded window. Commit to one endpoint form per fleet, run the five checks above on every remote unit after the change, and settle the VPN and firewall question as its own security decision.

Questions asked

Does the MQTT protocol itself require a numeric broker address?

No. The client stores a scheme, a host and a port, and resolution of the host happens on the client's own resolver before any TCP connection opens. The broker never learns whether the client dialed a name or a number; only the resolved address reaches it. Either form satisfies the protocol, so the choice is operational, not protocol.

How short should the DNS TTL be for a broker hostname?

As short as your DNS provider actually honors. Some hosting providers enforce their own minimum TTL or rate-limit how often a record may be updated, so the effective refresh can be slower than the value you configure. The TTL only bounds how long resolvers serve an old answer; it does nothing to speed up the updater that posts the new address.

Can some clients store the address while others store the hostname?

Yes, nothing prevents a mixed fleet, and every form that reaches the same listener works. It is still worth avoiding: after a change you must hunt down every variant, and with TLS enabled each form is checked differently against the server certificate. Standardize the fleet on one form before the number of remote units grows.

Does dynamic DNS still work if the broker sits behind network address translation?

Yes, but the name has to map to the address clients can actually reach. Behind a router with a provider-assigned public address, the updater must track the router's outside address and the router must forward the broker port to the server; without that forwarding, the name resolves and the connect still fails. Inside a tunnel, the name only needs to resolve there.

Keep reading

  • Troubleshooting

    Node-RED MQTT stuck on connecting inside a Docker container

    A Node-RED MQTT node stuck on connecting means no session was ever established: the transport connection to the server address and port never completed, or the broker declined the client. Test name resolution and routing from inside the container, then set the server to the broker's IP address and the port of its active listener. The controller's own IP works only when a broker actually listens there.

    Edge computing and IIoT

  • How-to

    Set an MQTT broker address dynamically in Node-RED flows

    You cannot inject a broker address into a running MQTT node, because the address belongs to the shared mqtt-broker configuration node. For a fixed change, edit that configuration node in the editor and deploy. For switching at runtime, Node-RED 2.1 and later support the connect, disconnect, subscribe and unsubscribe actions.

    Edge computing and IIoT

  • Troubleshooting

    MQTT sink stays offline until you use the broker IP address

    Your MQTT sink never reaches Online because localhost names the connector runtime's own loopback interface, not the broker. A pub/sub test from a separate client proves only that client's path. Replacing localhost with the broker's reachable IP address restored Online in the reported installation.

    Edge computing and IIoT

Why MQTT setpoint gating belongs in CODESYS, not the client