Troubleshooting
Modbus TCP Timeout or No Response: A Diagnosis Order That Works
Your Modbus client times out, or connects but reads nonsense. Work from the cable up to the register map and the fault reveals itself.
The symptom
A PLC polls an energy meter (or a drive, or a gateway) over Modbus TCP. The status shows timeout, connection refused, or the connection works but values are zero or garbage.
Diagnose from the bottom up. Each layer must work before the next one matters.
Layer 1 — Can you reach the device?
From an engineering laptop in the same subnet, ping the device. No reply:
Some devices block ping. If ping fails but you are confident in the address, go to Layer 2.
Layer 2 — Is port 502 open?
Use a Modbus test client (or Test-NetConnection in PowerShell). Connection refused means the device is reachable but nothing listens on 502 — Modbus TCP may be disabled in its settings, or it uses a different port. A gateway may also limit simultaneous connections; an old SCADA session can occupy the only slot.
Layer 3 — Unit ID
A native Modbus TCP device often ignores the Unit ID, but a TCP-to-RTU gateway uses it to pick the serial slave. Wrong Unit ID usually produces a timeout or exception 0x0B (gateway target failed to respond). Set it to the serial slave address of the device behind the gateway.
Layer 4 — Function code and address
Now the request reaches the device. Errors come back as exception codes:
| Exception | Meaning | Usual cause |
|---|---|---|
| 01 Illegal function | Function not supported | Reading input registers (FC04) from a device that only has holding registers (FC03) |
| 02 Illegal data address | Register does not exist | Off-by-one, or reading past the end of a block |
| 03 Illegal data value | Request malformed | Asking for too many registers in one read (limit is 125) |
Layer 5 — Value interpretation
Connection good, values wrong:
When to open Wireshark
Mirror the switch port, filter on tcp.port == 502, and compare request and response. You will see the exact function code, start address, quantity and any exception — the end of all argument between "the PLC is wrong" and "the meter is wrong".
Practise the full protocol in the Modbus TCP module.
Frequently asked questions
What does Modbus exception 02 mean?
Illegal data address: the register you requested does not exist on the device. Most often this is the 40001 versus 0 offset confusion, or reading past the end of a register block.
Why does my Modbus gateway time out?
Check the Unit ID matches the serial slave address behind the gateway, the serial settings (baud, parity) match the slave, and the gateway is not out of TCP connection slots.