Cannot Communicate with Node-Red Modbus Server (Slave)

I am having trouble establishing a healthy communications link with a Node-Red Modbus Slave.

I have created a Node-Red Modbus Slave on Laptop A, with the intent that it can be polled by a separate Modbus Master running on Laptop B (or other Modbus Master device connected on the same network).

I have created what I think should work (using the Modbus Server node) - see JSON flow code further below.

To test this I am attempting to use Modbus Poll (on Laptop B) to request the Modbus Registers from the Node-Red Modbus Slave (running on Laptop A). However, I cannot establish a healthy TCP connection.

Network Troubleshooting Notes:

  • Laptop A IP Address:
  • Laptop B IP Address:
  • Laptop B can successfully ping Laptop A
  • Subnet Mask and Default Gateway aligned between laptops

Node-Red Modbus Server configuration (Laptop A):

  • Hostname:
  • Port: 502

Modbus Poll configuration (Laptop B):

  • Connection: Modbus TCP/IP
  • Remote Modbus Server:
  • Server Port: 502

Note that in the Node-Red Flow I am initialising the Modbus Holding Registers with some values so that the Modbus Master (on Laptop B) has non-zero values to retrieve. This is why the Flow contains "Modbus Flex Write" and the associated "Modbus-Client node".

Node-Red Modbus-Client configuration (Laptop A):

  • Host:
  • Port: 502

Node-Red Troubleshooting Notes:

  • I have changed the Modbus Server "Hostname" between,, and (with no success)
  • Node-Red version: 3.1.5
  • Node.js version: v20.11.1
  • Palette: node-red-contrib-modbus (5.30.0)

Any advice for troubleshooting this TCP connectivity (between Laptop B and Laptop A) would be greatly appreciated.

Some questions I have:

  • The "Port" field for the Modbus Server Node suggests the available range is "2000 to 65536" (this is the grey text within the field when nothing is yet entered into the field). The default setting is 10502, but I have this set to 502, which is outside the "grey-text" range - is this an issue?
  • Are there specific Firewall rules that need to be enabled/disabled to allow Node-Red to communicate through?

If your OS is Linux (maybe macOS too - idk) there are permissions required to bind ports below 1000.

On windows, you'll likely need to open port 502 in the built in firewall.

Did you try accessing the server by adding a client on the same node-red?

Hi Steve,

Thanks for the prompt response.

  • I am running Windows
  • I have a Modbus Client on the same Node-Red and it can read and write from the Modbus Server correctly (within the same Flow).

Note I have tried to upload my JSON code here, but it is too many characters (>32000) - even though the flow is not actually that large/complex.

Forgot to ask. Is there a specific reason for using modbus? (There are much better ways to do intercommunication between Node-RED instances)

That suggests firewall to me.

You can select only the nodes of interest before export to minimise the export size

Yes, ultimately I need a Modbus Master device (a 3rd-party device) to retrieve Modbus from Node-Red (I am using Laptop B purely to troubleshoot before connecting the 3rd-party device).

I am using Node-Red to simulate a Modbus Slave (solar inverters), to allow easier testing on the bench.

1 Like

Modbus Server JSON:

        "id": "49bae4e7.6cc76c",
        "type": "modbus-server",
        "z": "3993d0ae18e25663",
        "name": "Modbus Server",
        "logEnabled": true,
        "hostname": "",
        "serverPort": "502",
        "responseDelay": 100,
        "delayUnit": "ms",
        "coilsBufferSize": "9999",
        "holdingBufferSize": "49999",
        "inputBufferSize": "9999",
        "discreteBufferSize": "9999",
        "showErrors": true,
        "x": 678.9999713897705,
        "y": 188.99999380111694,
        "wires": [

Modbus-Client JSON:

        "id": "ca982324.01be8",
        "type": "modbus-flex-write",
        "z": "3993d0ae18e25663",
        "name": "",
        "showStatusActivities": false,
        "showErrors": true,
        "showWarnings": true,
        "server": "48496f3b.10762",
        "emptyMsgOnFail": false,
        "keepMsgProperties": false,
        "delayOnStart": false,
        "startDelayTime": "",
        "x": 1210,
        "y": 380,
        "wires": [
        "id": "48496f3b.10762",
        "type": "modbus-client",
        "name": "local",
        "clienttype": "tcp",
        "bufferCommands": true,
        "stateLogEnabled": false,
        "queueLogEnabled": false,
        "failureLogEnabled": false,
        "tcpHost": "",
        "tcpPort": "502",
        "tcpType": "DEFAULT",
        "serialPort": "/dev/ttyUSB",
        "serialType": "RTU-BUFFERD",
        "serialBaudrate": "9600",
        "serialDatabits": "8",
        "serialStopbits": "1",
        "serialParity": "none",
        "serialConnectionDelay": "100",
        "serialAsciiResponseStartDelimiter": "",
        "unit_id": 1,
        "commandDelay": 1,
        "clientTimeout": 1000,
        "reconnectOnTimeout": false,
        "reconnectTimeout": 2000,
        "parallelUnitIdsAllowed": false,
        "showErrors": false,
        "showWarnings": true,
        "showLogs": true

To test the general Firewalls between laptops I have run up the Modbus Slave App (from Modbustools) on Laptop A.

With Laptop B (running Modbus Poll) I was then able to correctly read Modbus registers from Laptop A.

Given that Laptop B can't establish a healthy connection with the Laptop A Node-Red Modbus Slave, does this suggest that there are Firewall rules specific to Node-Red that I need to enable/establish?

Thanks for the prompt Steve, the solution was indeed a Firewall rule (on Laptop A running Node-Red).

I created a new Firewall rule specifically allowing Inbound TCP Port 502.

I'm slightly confused given that other TCP Port connections (such as 503) were working despite not having a dedicated Firewall rule allowing them.

But this has it working, and I'm grateful. Thankyou.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.