PortDock

Modbus TCP not connecting — checking port 502, unit ID and connection limits

Ping works but Modbus TCP does not? Check layer by layer — network, port 502, MBAP reply, values — for subnet, firewall, port, unit ID and connection limits.

Modbus TCP sends the Modbus request (PDU) over TCP with a 7-byte MBAP header in front. There is no RTU CRC, and the MBAP unit ID takes the place of the slave ID. «It doesn't work» happens at one of the four layers below, so check them bottom-up. Specification details follow the Modbus Messaging on TCP/IP Implementation Guide V1.0b.

LayerCheckIf it passes
1. NetworkSame subnet? Do ARP and ping reach it?The device is on the network
2. TCP connectionDoes port 502 (or the configured port) accept?A Modbus server is listening
3. Modbus replyDoes a request get an MBAP reply?Unit ID and function fit
4. ValuesDo the values make sense?Address notation and word order fit

1. Network: start with the subnet

Factory devices often ship with fixed IPs such as 192.168.1.x; if the PC is on another subnet, not even ping gets through. Adding a second IP on that subnet to the PC reaches the device without dropping your current network (e.g. device 192.168.1.10 → PC 192.168.1.200, mask 255.255.255.0). Some devices block ping, so «no ping» alone does not prove the device is absent — on the same subnet ARP still finds it.

2. Does port 502 accept a connection?

3. Connected but no reply: MBAP and unit ID

A request reading two holding registers from address 0, and its reply (values 100 and 200):

Request   00 01 00 00 00 06 01 03 00 00 00 02
Response  00 01 00 00 00 07 01 03 04 00 64 00 C8
BytesMeaning
00 01Transaction ID — copied into the reply by the server
00 00Protocol ID — 0 for Modbus
00 06Length — bytes that follow (unit ID + PDU)
01Unit ID
03 00 00 00 02PDU — function 03, start address 0, quantity 2

4. Connections drop or will not come back

Replies arrive but values look wrong

That is interpretation, not communication. Values shifted by one point to address notation (0-based, 40001); wrong 32-bit values only point to word order. For exception replies, see the exception table in the no-response checklist.

In PortDock

Published 2026-10-22