When a Modbus slave cannot fulfil a request, it does not stay silent. It answers with an exception response: the original function code with the high bit set, followed by a single exception code byte.
That one byte is the fastest diagnostic signal in the protocol. Learn to read it and most field problems resolve in seconds.
Take a normal request for holding registers:
Request : 01 03 00 00 00 0A C5 CD
^^ ^^ ^^^^^ ^^^^^ ^^^^^
ID FC addr qty CRC
If the slave rejects it, the response is two bytes plus CRC:
Response: 01 83 02 C0 F1
^^ ^^^^^ ^^^^^
ID FC code
83 = 03 with the high bit set (0x03 | 0x80). This is how the master knows it is an error, not data.02 = Illegal Data Address.FC | 0x80 is exactly 5 bytes in RTU (1 ID + 1 FC + 1 code + 2 CRC) and 9 bytes in TCP.| Code | Name | Typical real-world cause |
|---|---|---|
01 | Illegal Function | The slave does not implement that function code at all. Often a device that only supports read functions receiving a write, or a gateway that does not pass 0x17 through. |
02 | Illegal Data Address | The requested address (or address + quantity) falls outside the slave's implemented range. This is the most common exception by far. |
03 | Illegal Data Value | The address was valid but the value was not — quantity 0, quantity above the device limit (often 125 registers / 2000 coils), or an out-of-range write value. |
04 | Server Device Failure | The slave hit an internal fault while executing. Hardware problem, sensor fault, EEPROM write failure. |
05 | Acknowledge | The command was accepted but will take a long time. The master should poll later rather than retry immediately. |
06 | Server Device Busy | The slave is processing a long command and cannot accept a new one. Back off and retry. |
08 | Memory Parity Error | The slave detected a parity error in its own memory (extended file record access). Rare outside legacy devices. |
0A | Gateway Path Unavailable | The gateway is configured correctly but has no route to the target device — usually a downstream RS-485 segment that is misconfigured or offline. |
0B | Gateway Target Device Failed To Respond | The gateway tried the target device and got no reply at all — time-out on the downstream side. The device is unpowered, wrong slave ID, or wrong baud rate. |
These two account for the majority of field calls, and they mean opposite things:
If you see 0x0B, stop checking your register map. Check the physical layer.
Modbus protocol addresses are zero-based. Device documentation is almost always one-based. Holding register 40001 in a datasheet is PDU address 0.
If a device manual says "Holding Register 40011" and you send address 40011 (or even 11 when the block starts at 40001), you get 0x02. The correct PDU address is 10.
Rules that hold in practice:
4xxxx fifth-digit prefix is a convention, not part of the address. Strip it.40001 → PDU 0. 40011 → PDU 10.10001 → 0, 00001 → 0.If you are using pymodbus, exceptions surface as typed errors rather than raw bytes:
from pymodbus.exceptions import ModbusIOException, ExceptionResponse
from pymodbus.pdu import ExceptionResponse as ExcResp
rr = client.read_holding_registers(address=0, count=10, slave=1)
if isinstance(rr, ExcResp):
print(rr.exception_code) # 2
elif rr.isError():
print("transport error:", rr)
If you are parsing raw frames yourself, the check is one line:
if fc & 0x80:
raise ModbusException(f"slave {unit} returned 0x{code:02X}")
0x02 = address; 0x0B/0x0A = gateway path; 0x04/0x06 = device health.0x02, halve the problem. Request a single register at address 0. If that works but address 10 fails, your block offset is wrong. If address 0 fails too, the function code or the device's implemented range is wrong.0x03, check quantity limits. Many devices cap register reads well below the protocol maximum of 125.You can reproduce all of this without hardware on the ModbusLab TCP slave, which accepts real Modbus TCP connections on port 502, or decode frames byte by byte in the message lab.