IMD SolutionComputing LibraryShop main store

Troubleshooting

Modbus RTU over TCP fails in a Proxmox LXC container

Edge computing and IIoT Published 8 min read

Short answer

A passing ping from the LXC container clears the network, not the Modbus transaction. A desktop client read the same gateway with RTU-over-TCP framing while Node-RED failed, and the gateway's own configuration was at fault: match transport framing, TCP port and unit ID on both ends, keep one client connected during tests, and rebuild the gateway configuration if matched settings still fail.

On this page
  1. Why does the client report 'fsm failed state after sending'?
  2. Does a ping from inside the LXC container prove the Modbus path works?
  3. Is the Proxmox container itself causing the failure?
  4. Is the gateway carrying Modbus TCP or Modbus RTU over TCP?
  5. What does an RTU-over-TCP request look like on the wire?
  6. What has to match between Node-RED and the gateway?
  7. When is rebuilding the gateway configuration the fix?
  8. Questions asked

A Modbus client in Node-RED that lands in its failed state right after sending, while a ping from the same Proxmox LXC container passes, is almost never a container-network problem: the request left Node-RED and nothing usable came back. In the case behind this article, a desktop client reached the same serial-to-Ethernet gateway with RTU-over-TCP framing and read the PT100 values, Node-RED did not, and the gateway's own configuration finally turned out to be wrong. Match the transport framing, the TCP port and the unit ID on both sides, keep one client connected at a time, and rebuild the gateway configuration when matched settings still fail.

Why does the client report 'fsm failed state after sending'? #

The message means the client node's internal state machine sent the Modbus request and then dropped into its failed state because no valid response arrived before the node's timeout — the TCP connection is not the suspect, the unanswered transaction is.

The Modbus client in node-red-contrib-modbus is driven by an internal state machine, and its states are visible: the same machine that reports the failed state after a send also reports when it is not ready to read, and installations build disconnection alarms on those states. The text captured in this case, Client -> fsm failed state after sending Get More About It By Logging, is the machine reporting the transition plus the node's own hint to switch on logging. That logging uses the debug package rather than ordinary debug nodes, so enable it as the package documentation describes before changing anything else.

Then order the work by layer. A request that left Node-RED and produced no usable reply puts the fault above IP and below the application: in the TCP payload handling or on the serial leg. That transport-first, application-second ordering is the same one that applies when MQTT connect fails while TCP works, and it holds here unchanged.

Does a ping from inside the LXC container prove the Modbus path works? #

No — the ping in this case proved only that the container could reach the gateway at 192.168.1.201 over ICMP, which says nothing about port 8887, Modbus framing, or the RS-485 leg, and the client still failed immediately after that check passed.

ICMP reachability clears layer 3 and nothing else. It does not test whether anything is listening on the gateway's TCP port, whether the bytes after the handshake parse as the framing the gateway expects, or whether the gateway can deliver anything onto its serial side. A serial-to-Ethernet gateway can accept the TCP connection and still be unable to make sense of the request inside it, which is exactly the shape of this failure: the ping node inside Node-RED succeeded, and the Modbus transaction immediately after it failed.

Treat the ping as one cleared layer and move down. Retest from inside the same container that runs Node-RED — a ping from the Proxmox host proves the host's network, not the container's — then go straight to the Modbus conversation instead of re-testing ICMP.

Is the Proxmox container itself causing the failure? #

Almost never once ping and the TCP connect both succeed: an LXC container on a standard bridge forwards TCP payloads byte for byte, so a framing mismatch between Node-RED and the gateway behaves exactly as it would on a bare-metal install.

An LXC container gets its network through a virtual Ethernet pair attached to a bridge; the bridge moves frames, it does not interpret Modbus. If the request leaves the container intact, the container cannot be the reason the gateway rejects the framing. That is why the container sits last on the suspect list once both checks pass.

The container becomes the suspect in one pattern only: ping or the TCP connect fails from inside the container while the same tests succeed from the Proxmox host. Then inspect the container's network attachment, its address and default route, and any firewall rule between the container and the gateway — and retest from inside Node-RED itself, because the container's network namespace is what Node-RED actually uses. When ping and connect both pass, stop tuning networking and go to the framing.

Is the gateway carrying Modbus TCP or Modbus RTU over TCP? #

The working desktop client connected with the mode shown as 'modbus RTU over TCP/IP', which carries a complete RTU frame — unit address, function code, data and a two-byte CRC — inside TCP, while a native Modbus TCP client sends a different frame that carries no CRC at all.

Native Modbus TCP wraps every request in a 7-byte MBAP header — transaction identifier, protocol identifier, length, unit identifier — and appends no error check. An RTU-over-TCP gateway instead expects the bare serial frame: unit address, function code, data and a two-byte CRC-16, exactly what the device would send on the wire. The two are not interchangeable. A gateway configured for one cannot parse the other into a valid transaction, and a client set to the wrong one fails after connecting, which looks misleadingly like a network problem.

Decide the mode from evidence, not from names: read the mode in the gateway's own configuration interface or manual, and compare it with the connection mode the successful desktop client used. The phrase 'Modbus TCP' on a gateway label or in a symptom description proves nothing about which framing the Ethernet side actually accepts.

What does an RTU-over-TCP request look like on the wire? #

A read of one register from unit 1 needs an 8-byte RTU frame, while the identical request in native Modbus TCP framing needs 12 bytes with a 7-byte header in front, and that 4-byte difference is exactly what breaks a gateway set for RTU over TCP.

Take the smallest useful read as the worked example: unit 1, function 03, start address 0, one register — a typical first poll of a PT100 input register. These are example values; the frame structures come from the Modbus specification.

  • Native Modbus TCP, 12 bytes: 00 01 transaction + 00 00 protocol identifier + 00 06 length + 01 unit + 03 function + 00 00 start + 00 01 quantity. Arithmetic: 2 + 2 + 2 + 1 + 1 + 2 + 2 = 12 bytes, and the length field itself says 6 — the six bytes that follow it.
  • RTU over TCP, 8 bytes: 01 unit + 03 function + 00 00 start + 00 01 quantity + 84 0A CRC. Arithmetic: 1 + 1 + 2 + 2 + 2 = 8 bytes. The trailing 84 0A is the CRC-16 that the standard worked example for this exact request ends in.

Now watch a gateway set for RTU over TCP receive the TCP frame. It reads byte 1 — 00, the transaction counter's high byte — as a unit address, a value RTU reserves for broadcast. It reads bytes 7 and 8, where the CRC belongs, and finds 01 03 instead of a matching check value. The frame fails the CRC test, no RTU response is ever generated, and the Node-RED client times out into its failed state. No choice of transaction identifier or register makes a 12-byte header-carrying frame validate as an 8-byte CRC-checked one: the lengths alone differ by 4 bytes.

What has to match between Node-RED and the gateway? #

Five things must agree: the transport framing, the gateway address, the TCP port — 8887 in this case — the unit ID, shown as 1 by default, and the gateway's RS-485 serial settings against the probe's own configuration.

Set both ends from the working client outward, one change at a time, and note the previous value of each setting so you can tell which mismatch mattered:

  • Transport framing in the Node-RED client node: set it to the framing the gateway actually carries, matching the working client's RTU-over-TCP connection mode. If your client node offers no RTU-over-TCP framing option, prove the gateway mode with a client that does before blaming the gateway.
  • Destination: the gateway at 192.168.1.201 listening on port 8887, exactly as the gateway's own configuration shows.
  • Unit ID: the working test used the default of 1; the correct value is the probe's configured RTU address as the gateway routes it downstream.
  • RS-485 side: baud rate, parity and stop bits must match the PT100 module's own serial settings; a request can pass at the framing level and still fail here.
  • One client at a time: leave the desktop client disconnected while Node-RED polls, because many such gateways serve a single TCP session.
  • Response timeout: give the client enough headroom for the serial turnaround on top of the network leg.

Each item is a one-field comparison. Change one, retest, and only then move to the next.

When is rebuilding the gateway configuration the fix? #

When Node-RED uses the same framing, port and unit ID as the working client and still lands in the failed state, the gateway configuration is the remaining suspect — in this case that is where the fault sat, and re-entering the gateway's configuration from scratch cleared it.

Record the gateway's current configuration first, then rebuild it deliberately: set the Ethernet-side mode to the framing the working client used, re-enter the listening port, the downstream unit routing and the RS-485 serial parameters against the probe's documentation, and save. Rebuild only after the Node-RED side is demonstrably matched to the working client — otherwise you are changing two unknowns at once.

Map each result to its next move:

  • Ping fails from inside Node-RED: fix the container's bridge attachment, address or route — networking, not Modbus.
  • Ping passes, TCP to the gateway port fails: check the listener port and any filtering between container and gateway.
  • TCP connects, Modbus fails: align transport framing, unit ID and the gateway's RTU side; this case lived here.
  • Matched settings still fail: rebuild the gateway configuration, as this case's fix did.
  • Another client works while Node-RED fails: compare both clients field by field and never let them poll simultaneously.

Verify the fix where it counts: from inside Node-RED, read the same register the desktop client reads, and read it repeatedly — a dozen clean responses, not one. A ping or an open socket proves nothing about the transaction. Once readings hold, if values then disappear between Node-RED and a broker, tracing missing Modbus data from Node-RED to an MQTT cloud continues the same hop-by-hop method one layer up.

The decision, in order: framing first, container last, gateway configuration as the tiebreaker — and treat every pass below the application layer as clearance, not proof.

Questions asked

How do I see what the Modbus client's state machine is doing?

The client node in node-red-contrib-modbus exposes state transitions as messages, and the failed state after a send is one of them. Its logging uses the debug package rather than ordinary debug nodes, so enable debug logging the way the package documentation describes. Reading the state before the send and after the timeout tells you whether the request left Node-RED at all, which separates a client-side fault from a gateway or RS-485 fault.

Can the desktop Modbus client stay connected while Node-RED polls?

Disconnect it. Many serial-to-Ethernet gateways serve a single TCP session at a time, so a desktop client left open can hold or steal the session Node-RED needs and produce the same failed state as a framing mismatch. Keep exactly one client connected during every test, and allow simultaneous clients only once the gateway documentation confirms it supports them.

Is unit ID 1 a requirement for this setup?

No. 1 was the default the client showed, not a rule. The value that must be sent is the probe's configured RTU address as the gateway routes it downstream: if the PT100 module answers at address 5, for example, both the desktop client and Node-RED must send unit ID 5, and the gateway must forward that address to the serial side unchanged.

Does the same failure shape apply to a gateway running native Modbus TCP?

Yes, with the roles reversed. A gateway running as a native Modbus TCP server expects the 12-byte header-carrying frame with no CRC, and a client sending RTU frames into it fails in the same after-send way. Identify the gateway's Ethernet-side mode first, set the client to match it, and use the wire comparison of 12 bytes against 8 to tell the two framings apart in a capture.

Keep reading

  • How-to

    MQTT to Modbus TCP with Node-RED on an edge gateway

    Yes: Node-RED with the node-red-contrib-modbus package can serve MQTT data to a SCADA client as Modbus TCP. Read the RTU device in Node-RED first, give the Modbus server node a port nothing else owns, and scale each MQTT payload to one integer per holding register before the first end-to-end test.

    Edge computing and IIoT

  • Explainer

    Edge gateway Modbus TCP polling over the WAN port

    When a data gateway supports MQTT as a client only, drop the broker hop: configure the Modbus TCP poll to target the device's IP address in the same subnet as the gateway's WAN interface. The gateway opens the TCP connection itself, so polled values keep updating with the internet link down. Verify by pulling the uplink and watching one known register.

    Edge computing and IIoT

  • Troubleshooting

    Sparkplug node stuck on Connecting while MQTT connects

    The node-red-contrib-sparkplug node takes its broker string literally and adds no transport scheme, so a bare IP:port is rejected before any connection attempt and the node sits on Connecting with no error. Write the broker as a full URI — tcp://192.168.1.50:1883 for plaintext or ssl://host:8883 for TLS — deploy, and it connects where the default MQTT node already did.

    Edge computing and IIoT