Tutorials › Modbus Error Codes

When a Modbus device cannot satisfy a request, it replies with an exception response: the original function code with the high bit set, followed by a one-byte exception code. Knowing these codes turns a frustrating "it doesn't work" into a quick fix.

The common exception codes

0x01
Illegal Function

The device does not support that function code. Use a different function (e.g. FC 04 instead of FC 03) and check the device docs.

0x02
Illegal Data Address

The address does not exist on the device. The most common cause is 0-based vs 1-based addressing - if the manual says 40001, use address 0. Also try a smaller quantity.

0x03
Illegal Data Value

The value or quantity in the request is out of range for the device. Check valid ranges and limits in the documentation.

0x04
Slave Device Failure

An unrecoverable error occurred inside the device while processing the request. Retry, and check the device status/logs.

0x05
Acknowledge

The request was accepted and is being processed (used with long operations). Not an error - poll again shortly.

0x06
Slave Device Busy

The device is busy with another command. Wait and retry.

Errors that are not exception codes

Two of the most common problems never produce an exception code at all, because nothing comes back:

  • Timeout - no reply arrived. Check the IP/port (TCP) or COM port and serial settings (RTU), confirm the slave ID, and verify wiring. Increase the timeout for slow devices.
  • CRC error (RTU) - the reply was corrupted or the serial settings are wrong. Make sure baud rate, parity, data bits and stop bits exactly match the device, and that the RS-485 bus is terminated.

Diagnose faster with ModbusBB

ModbusBB shows the exact request and response in its communication log, decodes exception codes for you, and includes a slave scanner, register scanner and ping tool to track down addressing and connectivity problems. Download the free trial or read the troubleshooting guide.

Put It Into Practice

Test, simulate and debug Modbus devices with one tool.