Raspberry Pi Modbus TCP, port 502 not listening

I installed node-red in my Raspberry Pi, and would like to apply with Modbus TCP; however, it is not listening on port 502. Please help..

pi@raspberrypi:~ $ netstat --tcp --listening
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0* LISTEN
tcp 0 0* LISTEN
tcp 0 0 localhost:ipp* LISTEN
tcp 0 0* LISTEN
tcp 0 0 localhost:postgresql* LISTEN
tcp6 0 0 [::]:9001 [::]:* LISTEN
tcp6 0 0 [::]:5900 [::]:* LISTEN
tcp6 0 0 [::]:http-alt [::]:* LISTEN
tcp6 0 0 [::]:http [::]:* LISTEN
tcp6 0 0 [::]:ssh [::]:* LISTEN
tcp6 0 0 localhost:ipp [::]:* LISTEN
tcp6 0 0 localhost:postgresql [::]:* LISTEN
tcp6 0 0 [::]:1883 [::]:* LISTEN
tcp6 0 0 [::]:https [::]:* LISTEN


6 Nov 19:07:01 - [info]

Welcome to Node-RED

6 Nov 19:07:01 - [info] Node-RED version: v0.19.5
6 Nov 19:07:01 - [info] Node.js version: v8.11.1
6 Nov 19:07:01 - [info] Linux 4.14.71-v7+ arm LE
6 Nov 19:07:03 - [info] Loading palette nodes
6 Nov 19:07:07 - [warn] [modbustcp-no-pooling-server] Deprecated call to RED.runtime.nodes.registerType - node-set name must be provided as first argument
6 Nov 19:07:07 - [warn] [modbustcp-no-pooling-write] Deprecated call to RED.runtime.nodes.registerType - node-set name must be provided as first argument
6 Nov 19:07:07 - [warn] [modbustcp-no-pooling-read] Deprecated call to RED.runtime.nodes.registerType - node-set name must be provided as first argument
6 Nov 19:07:08 - [info] Dashboard version 2.10.1 started at /ui
6 Nov 19:07:09 - [info] Settings file : /home/pi/.node-red/settings.js
6 Nov 19:07:09 - [info] Context store : 'default' [module=memory]
6 Nov 19:07:09 - [info] User directory : /home/pi/.node-red
6 Nov 19:07:09 - [warn] Projects disabled : editorTheme.projects.enabled=false
6 Nov 19:07:09 - [info] Flows file : /home/pi/.node-red/flows_frisco-pi-2.json
6 Nov 19:07:09 - [info] Server now running at
6 Nov 19:07:09 - [warn]

Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.

6 Nov 19:07:09 - [info] Starting flows
6 Nov 19:07:09 - [info] Started flows

The node-red Modbus client nodes are used to connect to and read data from a previously installed and running OPC server -- which does not appear to be running on your raspberry pi (which is not surprising). So where is the server actually running?

Thanks Steve, I am looking to have node-red to connect with 502 and read data from an external Modbus client which is sitting on the same vlan. How can I make it work like the youtube describe below? Do I have to install an OPC on my raspberry pi?

Ah, ok, I thought you were looking on the local pi for the modbus server...

I noticed that last line says it's showing only servers -- but yes, if the server is on your lan, you should be able to connect to the remote port 502, giving the hostname or ip addr of the remote server.

Does the modbus-read node ever get connected to the server? What makes you think that it's not listening? A picture of your flow may be helpful here, since most of us are not going to be able to import a flow that contains modbus and serial nodes.

FYI, please edit your original post and put a separate line containing 3 backtics (```) before and after your flow json. This keeps the discourse forum from formatting the text for display, and potentially messing up quotes and other characters, which makes the flow not able to be imported.

I believe that with modbus TCP you have to have a server. If the external device is a client (not a server) then you have to run a server for it to connect to. Then the node-red node can also connect to that server. If, however, the external device can operate as a server then do that and the node red node should be able to connect to it.

I run a capture using tcpdump, look like node-red (IP: is sending a random port instead of port 502. Is there anyway to bind it for port 502?

10:50:24.048609 IP > Flags [S], seq 793996539, win 29200, options [mss 1460,sackOK,TS val 3542014307 ecr 0,nop,wscale 7], length 0
10:50:24.258612 IP > Flags [R.], seq 0, ack 793996540, win 0, length 0

I believe you are misinterpreting that. I believe it is saying that 0.13 has sent to 0.12 port 502, then 0.12 replies to 0.13 port 53660

I concur with Colin... it looks like thngs are working ok. But you didn't answer my other questions:

Do you have any nodes wired to the input of the modbus node? Is it configured to poll the server?

What I tried to do was to have Node-Red query/Read Modbus Master/Server over TCP.

I have the config below at node-red


Both of them are on the same network. (Node-red) --> (Modbus Server)

You didn't answer the question about what you have wired to the input.
Also what is it that is not working.

the input should be sent from Modbus Server via TCP, right? the node-red I want to use is just capture from Modbus Server/PLC.

You still haven't told us what isn't working.

My node-red fails to connect to Modbus server via TCP. It keep re-initiates the connection.

What is the device you are trying to connect to, and can you point to some docs that say how to use it as a modbus tcp server?