Improve TCP nodes (IP and Port programmatically)

It would be nice if the IP and Port on the TCP nodes could be inserted with variables or through messages.


The tcp-request node supports this as it is intended for short lived connections. The in and out nodes are more intended for long lasting connections either as a server or client, so are not expected to change hosts and ports, though they can be set as environment variables.

Thanks for the reply.

I didn't know the field could take environment variables.

My goal is to load the IP and port from a configuration file.
Would you know if I can put these into a specific file instead of using settings.js (as explained in the Node-Red documentation)?

Thank you.

Well settings.js is an executable file so it can be edited to add code to read in from another file if you wish. Or you can set env variables outside of node-red before starting it.

1 Like

How can set the tcp-in node to listen a port that is set on an environment variable?
Edit: I mean the tcp-in node working as a server.

You can use an environment variable in any field in any node using ${ENV_VAR} in the node configuration. See Using environment variables : Node-RED