# Tcp-in node "listen-to" mode: listen on non-localhost?

**URL:** <https://discourse.nodered.org/t/tcp-in-node-listen-to-mode-listen-on-non-localhost/97849>\
**Category:** General\
**Created:** [28 June 2025 10:33 UTC](https://discourse.nodered.org/t/tcp-in-node-listen-to-mode-listen-on-non-localhost/97849 "2025-06-28T10:33:02Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [28 June 2025 10:33 UTC](https://discourse.nodered.org/t/tcp-in-node-listen-to-mode-listen-on-non-localhost/97849/1 "2025-06-28T10:33:02Z")

</div>

Hi There,

Just as followup on my [tcp nodes question](https://discourse.nodered.org/t/tcp-in-modes-what-is-the-difference-between-connect-to-and-listen-to/97834), I'm wondering is it possible to listen to something non-localhost:

 ![Screenshot 2025-06-28 at 12.29.30](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/c/7c8e9901a16ea2176efffc37a216c9c6a36307b8.png)

That configuration is: Tcp in node should start a server on port 1231 on host localhost right?

What if I want to start a listener on 192.178.100.23 ? Is that possible?

I can connect to a specific server but I can't start a server on a specific host ip - what am I missing?

Cheers!

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [28 June 2025 13:29 UTC](https://discourse.nodered.org/t/tcp-in-node-listen-to-mode-listen-on-non-localhost/97849/2 "2025-06-28T13:29:53Z")

</div>

If I am not mistaken, it will use the primary interface, or first or something - not sure how the decision is made - it may listen on all interfaces actually?

But behind the scenes it's using the `net` class, which has a `listen` method, that allows to specify the address (interface)

So is it possible - yes, just needs a Feature Request to expose the ablity

```auto
const socket = net.createServer(...)
socket.listen(1231,'192.178.100.23')
socket.on('data', function(d){
  // Do stuff
})

/* etc etc */

```

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [28 June 2025 13:54 UTC](https://discourse.nodered.org/t/tcp-in-node-listen-to-mode-listen-on-non-localhost/97849/3 "2025-06-28T13:54:25Z")

</div>

The node doesn't pass any IP address when opening the server socket, so binds to all available IP addresses on all interfaces.

> <https://github.com/node-red/node-red/blob/01815b995e1bf2c87a82afe1a51d563a2d83fe31/packages/node_modules/%40node-red/nodes/core/network/31-tcpin.js#L293>

It is not currently possible to bind to a specific IP/interface.

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [28 June 2025 15:55 UTC](https://discourse.nodered.org/t/tcp-in-node-listen-to-mode-listen-on-non-localhost/97849/4 "2025-06-28T15:55:26Z")

</div>

> [@hardillb](#):
>
> binds to all available IP addresses on all interfaces.

ok, good to know - I would have assumed only localhost but that makes absolutely no sense (when I think about it).

> [@hardillb](#):
>
> It is not currently possible to bind to a specific IP/interface.

😮 I find that weird that no one has wanted that feature - I mean it is really not unusual for servers to have multiple interfaces, basically every server has localhost and external interface but in that case binding to all interfaces makes no difference.

> [@marcus-j-davies](#):
>
> yes, just needs a Feature Request to expose the ablity

won't be that hard since everything is there - host configuration is only hidden if listen to is selected, so basically don't hide the input field! 😉 In fact, I can enter a host to connnect to, then switch to listen to and the host is still there in the configuration even if the field is hidden 😉

on the other hand, I assume that if it's not been an issue in the past ten years, it ain't that important - unless you're like me and like to dissect nodes ...

EDIT: sorry forgot: thanks to both of you for the answers 👍

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [28 June 2025 22:22 UTC](https://discourse.nodered.org/t/tcp-in-node-listen-to-mode-listen-on-non-localhost/97849/5 "2025-06-28T22:22:53Z")

</div>

I can’t check right now but you may be able to see where the incoming connection is coming from so even if all interfaces are allowed then you could filter if necessary. ( maybe )

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [29 June 2025 05:55 UTC](https://discourse.nodered.org/t/tcp-in-node-listen-to-mode-listen-on-non-localhost/97849/6 "2025-06-29T05:55:51Z")

</div>

> [@dceejay](#):
>
> see where the incoming connection is coming from

True, that's the case:

 ![Screenshot 2025-06-29 at 07.52.57](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/7/67034e0ae6748e8d79227c3299fd049c24409e04.png)

the `ip` value is the ip of the interface the tcp in node is connected to and not the ip of the incoming server.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [29 June 2025 11:12 UTC](https://discourse.nodered.org/t/tcp-in-node-listen-to-mode-listen-on-non-localhost/97849/7 "2025-06-29T11:12:32Z")

</div>

I think that it would be reasonable to add an input to the node to allow restricting to a specific interface? Node-RED itself can be restricted via settings.js and it is good practice to only allow access on a specific interface.

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [29 June 2025 13:25 UTC](https://discourse.nodered.org/t/tcp-in-node-listen-to-mode-listen-on-non-localhost/97849/8 "2025-06-29T13:25:00Z")

</div>

> [@TotallyInformation](#):
>
> good practice to only allow access on a specific interface.

exactly and that's why I asked whether that was possible with the tcp in node. I never thought of a global configuration for something that is relatively specific to the tcp in node.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [13 July 2025 13:25 UTC](https://discourse.nodered.org/t/tcp-in-node-listen-to-mode-listen-on-non-localhost/97849/9 "2025-07-13T13:25:07Z")

</div>

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