IMD SolutionComputing LibraryShop main store

Troubleshooting

MQTT sink stays offline until you use the broker IP address

Edge computing and IIoT Published 6 min read

Short answer

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.

On this page
  1. Why localhost fails while your test client connects
  2. Check the path in this order
  3. Apply the fix
  4. Worked example: connector in a container, broker at 192.168.1.35 on port 1883
  5. Keep the other changes separate
  6. Online is not delivered data
  7. Questions asked

Your MQTT sink never reaches Online because localhost does not name the broker from where the connector runs. The name resolves inside the connector's own runtime — the loopback interface of its host, virtual machine, or container — and the broker's listener sits on a different interface. Replacing localhost with the broker's actual IP address in the sink configuration took the connector to Online in the installation that reported this fault. Your separate pub/sub test proved only the test client's path, not the connector's. Work the destination first, the listener second, the MQTT session last.

Why localhost fails while your test client connects #

localhost is resolved by each client's own network stack, not by the network. On a Linux runtime, cat /etc/hosts shows the mapping, typically an entry like 127.0.0.1 localhost. Inside a container or virtual machine, that loopback belongs to the container or VM, not to the machine hosting the broker; the documented container guidance is to link the networks or address the broker container by name rather than rely on localhost. The sink and your test client can therefore read the same hostname text and still dial two different addresses.

MQTT Explorer succeeded because it resolved localhost in its own context, typically the same machine or segment as the broker. A ping of localhost confirms the mapping and an ICMP reply, never an MQTT session on port 1883.

The fault has a mirror image on the broker side: the stock Mosquitto listener binds to localhost only, so clients outside that context cannot connect even at the correct address — the failure you chase when devices cannot publish to a broker on your PC.

Check the path in this order #

  1. Identify where the connector executes: directly on a host, in a virtual machine, or in a container. Every test below runs from that context, not from your workstation.
  2. Confirm what localhost resolves to there: read /etc/hosts and expect the 127.0.0.1 localhost entry.
  3. Read the broker's listener configuration: the interface address it binds and the port — 1883 in the documented examples.
  4. Test the TCP destination from the connector context. A refused connection means nothing accepted a connection at that address and port from there; a timeout points instead at routing or a firewall.
  5. Read the broker's connection log. A connection attempt visible at the broker means the destination is right and you have moved into session setup; a rejection recorded there points at credentials and access rules.

The principle reaches beyond MQTT: test from the client's own context, not from wherever happens to be convenient — the same discipline that fixes an HMI whose email never reaches its server. And if you stand up a broker purely to test against, run a secure Mosquitto lab broker with Node-RED rather than trusting default listener behavior.

Observation What it establishes Next check
Test client connects, pub/sub works That client's destination and credentials are good Where that client runs versus where the connector runs
TCP connect to the broker address and port is refused No listener at that destination from that context Listener binding address and port
Broker log shows a rejected connection The request reached the broker's MQTT handling The rejection detail and the sink's credentials

Apply the fix #

  1. Read the broker listener configuration and note the interface address and port.
  2. Open the MQTT Sink configuration and replace localhost in the hostname field with the broker IP address reachable from the connector's network.
  3. Keep the listener port, transport mode, and authentication settings exactly as the working broker configuration documents them; an address fix must not become a security regression.
  4. Deploy and watch the status. When the dialed destination equals the listener, the status comes up on the next connection attempt.
  5. Record the working destination, port, connector version, and data-sharing state for the next maintenance event.

Worked example: connector in a container, broker at 192.168.1.35 on port 1883 #

Inputs:

  • MQTT Sink as configured: hostname localhost, port 1883 — the pattern that failed in the reported installation, with 1883 the listener port in the documented connection cases.
  • Connector runtime (illustrative case typical of this fault): inside a container on the plant-floor PC, whose /etc/hosts maps localhost to 127.0.0.1.
  • Broker (illustrative address of the kind in the documented refused-connection case): listening on the interface 192.168.1.35, port 1883.
  • Test client: MQTT Explorer on the engineering workstation, connecting successfully.
  • Observed behavior: no Online status after more than 30 s.

Rule in words: a connection can succeed only when the address and port the client dials after name resolution is identical to an address and port the broker has bound, reachable from the client's own network context.

Arithmetic:

  • Sink's dialed destination = resolve(localhost) + port = 127.0.0.1 + 1883 → 127.0.0.1:1883.
  • Broker listener = 192.168.1.35 + 1883 → 192.168.1.35:1883.
  • Compare 127.0.0.1:1883 with 192.168.1.35:1883: the ports match, the addresses do not → no listener matches the dialed destination → the connection cannot succeed no matter how healthy the broker is.
  • After the fix, the dialed destination is 192.168.1.35:1883, which equals the listener.

Result: with port, transport, and credentials unchanged, the connection request reaches the broker and the sink reports Online. In the reported installation, that single hostname change produced exactly that outcome.

Decision: whenever the broker runs outside the connector's own network namespace, configure the broker's address, never localhost. And once the broker is proven healthy from another client, treat more than about 30 s without an Online status as the trigger to change the configured destination — before touching credentials, connector versions, or anything else.

Keep the other changes separate #

The same installation also updated its IIoT Connector to version 1.0.7 and enabled data sharing, after which the status read Error with specific detail attached. Those changes improved the visible diagnostics; they were not the correction — the address replacement was. When you reproduce this, change one variable at a time: addressing first, then connector version, then data sharing, so the working combination stays identifiable.

Online is not delivered data #

Online certifies the session, not the payload path. A connected publisher can still write to the wrong topic or lack publish rights on the intended one.

  1. Confirm the MQTT Sink shows Online on the corrected address.
  2. Push an identifiable update through the configured dataflow.
  3. Subscribe to the expected topic with an authorized client and compare the received payload with the update.
  4. Read the connector and broker diagnostics during that test for connection or publication failures.

If the corrected address still leaves a client stranded short of the broker, work the remaining client-side failure points the way you would for a PLC MQTT client that never reaches its broker.

Questions asked

Why did MQTT Explorer connect when the MQTT Sink would not?

Your test client resolved localhost in its own context. If MQTT Explorer ran on the same machine or network segment as the broker, its route or loopback pointed at a live listener, so its connection succeeded. The connector resolves localhost inside its own runtime, where no broker is listening. Two clients reading the same hostname text can dial two different addresses, and only one of them has to work.

How do I test the broker destination from the connector's own context?

Open a shell where the connector actually runs - on its host, inside the virtual machine, or inside the container - and run a TCP connect test against the broker address and port, such as the documented listener on port 1883. A refused connection means nothing is listening at that destination from there; a timeout means routing or a firewall is in the way. Only a test from that context describes the connector's path.

How long should I wait for Online before I start troubleshooting?

The reported installation showed no status at all after more than 30 seconds while the broker was proven healthy by another client. Treat that as the trigger to act. Waiting longer or restarting the connector repeatedly changes nothing, because the destination it dials stays the same until you edit the hostname field.

Is a hostname better than the IP address in the long run?

A hostname survives a later broker address change, but only if the connector runtime's own resolver returns a reachable address for it. Validate resolution and the resulting connection from the connector context before substituting it. The IP address is the configuration that demonstrably restored Online, so keep it recorded as the known-good setting whatever you deploy afterward.

The status now reads Error with detail instead of nothing. Is that worse?

No, it is progress. An empty status means the connector never completed a connection worth reporting; Error with detail means the runtime is reporting a specific condition you can read and act on. In the reported installation this appeared after the connector update and the data-sharing change, separate from the address fix. Use the diagnostic text to identify the layer, and keep changing one variable at a time.

Keep reading

  • Troubleshooting

    Why a device cannot publish MQTT to a broker on your PC

    Point the device's client at the PC's LAN address, not 127.0.0.1 — loopback always means the device that opens the connection. Then confirm the broker listener is bound to the PC's LAN interface on TCP 1883 and that Windows Firewall admits inbound connections on that port from the plant subnet. Fix those three and the publish path works.

    Edge computing and IIoT

  • Troubleshooting

    Fix a PLC MQTT client that never reaches your broker

    Most PLC MQTT failures sit in one of three stages: the broker listener, the network path to the port the client is actually configured for, or the client's own publish logic. Test in that order; a connect timeout points to the first two, a silent publish to the third.

    Edge computing and IIoT

  • Troubleshooting

    Fixing MQTT cloud broker data not reaching SCADA tags

    Get the gate right first: MQTT over TLS belongs on port 8883, with the TLS mode and client identity the broker actually requires. An independent client such as MQTT Explorer on the same PC proves only its own settings, not the driver's. If the driver cannot perform the service-specific handshake Azure IoT Hub needs, no tag mapping will ever fill.

    Edge computing and IIoT