Modbus exception codes
When a Modbus device refuses a request it answers with an exception code. This page lists every code, what usually causes it and what to do about it.
How an exception looks on the wire
An exception response uses the function code of the request with the highest bit set (the function code plus 0x80), followed by one byte with the exception code. A request with function 03 that the device rejects with exception 02 is answered with 83 02. An exception means the device is alive and understood the frame; a missing answer is something else (see timeouts below).
Exception codes and what to do
| Code | Name and usual cause | What to try |
|---|---|---|
| 01 | Illegal Function The device does not support the function code in the request. | Check the device manual for the supported functions. Many devices read with 03 but have no 04, or accept 16 but not 06. |
| 02 | Illegal Data Address The start address, or start address plus quantity, is not a valid register or coil in the device. | Check 0-based and 1-based addressing: a manual that says 40001 usually means protocol address 0. Reduce the quantity so the block stays inside one valid range, or find the valid ranges with the Register Probe. |
| 03 | Illegal Data Value A value in the request is not allowed. Most often the quantity is too large, or the value to write is outside what the register accepts. | Stay within the protocol limits: 125 registers or 2000 coils per read, 123 registers or 1968 coils per write. Check the device manual for the allowed value range. |
| 04 | Server Device Failure The device accepted the request but failed while carrying it out. | Try again. If it repeats, check the device state and its own error log; the request itself is usually fine. |
| 05 | Acknowledge The device accepted a long-running request and is still working on it. | Do not repeat the request. Poll again later to see whether it has finished. |
| 06 | Server Device Busy The device is busy with a long command and cannot take this request now. | Retry after a short wait. Increase the delay between polls if it happens during normal polling. |
| 07 | Negative Acknowledge A programming request (function 13 or 14) was not successful. Rare; most devices never send it. | Check the device manual for the programming procedure. |
| 08 | Memory Parity Error The device found a parity error in its extended file memory (functions 20 and 21). | A device-side memory problem. Try again, then contact the device vendor. |
| 0A | Gateway Path Unavailable A gateway could not set up a path from its input port to its output port, often because it is misconfigured or overloaded. | Check the gateway settings and routing, and reduce the number of simultaneous requests. |
| 0B | Gateway Target Device Failed to Respond A gateway forwarded the request but the device behind it did not answer. | Check the slave ID, the serial wiring and the serial settings behind the gateway, and the device's power. |
Exception, timeout or error?
- Exception: the device answered with a code from the table. Fix the request.
- Timeout: no answer at all. Check the connection, the slave ID, the IP address and port or the serial settings, and whether another master is using the bus.
- Error (CRC, bad frame, connection closed): an answer arrived but is damaged, or the link was dropped. Check cables, termination and baud rate on serial lines, and the network path on TCP.
See the codes in Busscope
A poll window shows the device's answer in its status line, for example Exception 02: Illegal Data Address, and the traffic panel (F4) shows the exact frames. In the Request Runner an expectation of EX 02 passes when the device answers with exception 02; codes are written in hex like the table above, so EX 0A means code 10. An expectation of RESP 83 02 checks the complete exception frame. The Register Probe marks every address range with the exception it returned, which is the quickest way to find the valid addresses of an unknown device.
Try Busscope
Install Busscope and run it without a license key to see whether it fits your work. Evaluation mode is for trying the tool, not for production or commercial use.