# TCP in Node Red Docker Container

**URL:** <https://discourse.nodered.org/t/tcp-in-node-red-docker-container/83966>\
**Category:** General\
**Tags:** docker\
**Created:** [22 December 2023 18:43 UTC](https://discourse.nodered.org/t/tcp-in-node-red-docker-container/83966 "2023-12-22T18:43:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmcauliffe](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@jmcauliffe](https://discourse.nodered.org/u/jmcauliffe)\
**Post date:** [22 December 2023 18:43 UTC](https://discourse.nodered.org/t/tcp-in-node-red-docker-container/83966/1 "2023-12-22T18:43:07Z")

</div>

Hello,

I have node red running in a docker container on a raspberry pi and I am trying to send commands over TCP/IP using the TCP I/O node to another computer on my network that runs a server. However, because the docker container is on its own network within the pi (which is on the network the computer is on) and isn't addressable outside the pi I can't make the TCP connection. Is there any way to fix this inside of node red or will I have to create some sort of forwarding script to forward the TCP request from node red to the external server. Any help with this would be very appreciated. Thank you for reading and for helping with this.

---

<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:** [22 December 2023 18:51 UTC](https://discourse.nodered.org/t/tcp-in-node-red-docker-container/83966/2 "2023-12-22T18:51:15Z")

</div>

Welcome to the Forums @jmcauliffe

> [@jmcauliffe](#):
>
> Is there any way to fix this inside of node red

No. Node RED (or any other application) inside a container, will know nothing about the "real world".

Many here use Node RED bare metal, and do not use any form of OS layering. Unless someone here can advise (I'm sure some do use this type of setup) you will need to investigate how to configure your containers to use the real network.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [22 December 2023 19:08 UTC](https://discourse.nodered.org/t/tcp-in-node-red-docker-container/83966/3 "2023-12-22T19:08:35Z")

</div>

Your options are run node-red outside of a container, pop over to a docker forum and ask "what docker settings do I need to set to permit TCP communications in / out of a container" or read the docs...

> **[Networking overview](https://docs.docker.com/network/)**
>
> Learn how networking works from the container's point of view

You likely just want to use the host driver but you need to be aware of what that means to security and isolation.

In other words, probably wise to ask on a docker centric forum.

---

<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:** [22 December 2023 19:51 UTC](https://discourse.nodered.org/t/tcp-in-node-red-docker-container/83966/4 "2023-12-22T19:51:48Z")

</div>

It isn't too hard, you simply need to tell the container to expose the TCP/IP port you want to use. And just remember that the IP address of Node-RED seen from outside Docker will be different to inside.

---

<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:** [12 January 2024 20:53 UTC](https://discourse.nodered.org/t/tcp-in-node-red-docker-container/83966/5 "2024-01-12T20:53:14Z")

</div>

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