# Many gateways on one network

**URL:** <https://discourse.nodered.org/t/many-gateways-on-one-network/11972>\
**Category:** General\
**Created:** [8 June 2019 08:27 UTC](https://discourse.nodered.org/t/many-gateways-on-one-network/11972 "2019-06-08T08:27:04Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![sotiriszegiannis](https://avatars.discourse-cdn.com/v4/letter/s/f04885/32.png) [@sotiriszegiannis](https://discourse.nodered.org/u/sotiriszegiannis)\
**Post date:** [8 June 2019 08:27 UTC](https://discourse.nodered.org/t/many-gateways-on-one-network/11972/1 "2019-06-08T08:27:04Z")

</div>

Hi everyone. I would really appreciate it if anyone know if we can have more than one gateways in the same local network. At the moment if i put a second gw, there doesnt seem to be a way to change the default port 1880 to something else. I need the gateways to have different ports since i m sending commands to them. Any ideas anyone would be extremely appreciated.  
Thanks,  
Sotiris

---

<div class="post-metadata">

**Author:** ![mtoko](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mtoko/32/138_2.png) [@mtoko](https://discourse.nodered.org/u/mtoko)\
**Post date:** [8 June 2019 08:50 UTC](https://discourse.nodered.org/t/many-gateways-on-one-network/11972/2 "2019-06-08T08:50:30Z")

</div>

Hi

If you edit the settings.js file you will see the line

uiPort: process.env.PORT || 1880,

change the port number and then save the file. You will need to restart Node Red

---

<div class="post-metadata">

**Author:** ![sotiriszegiannis](https://avatars.discourse-cdn.com/v4/letter/s/f04885/32.png) [@sotiriszegiannis](https://discourse.nodered.org/u/sotiriszegiannis)\
**Post date:** [8 June 2019 09:03 UTC](https://discourse.nodered.org/t/many-gateways-on-one-network/11972/3 "2019-06-08T09:03:19Z")

</div>

Hi @mtoko and thank you for the reply. I ll give it a try.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [8 June 2019 10:17 UTC](https://discourse.nodered.org/t/many-gateways-on-one-network/11972/4 "2019-06-08T10:17:14Z")

</div>

> [@sotiriszegiannis](#):
>
> anyone know if we can have more than one gateways in the same local network

What do you mean by a 'gateway'. If they are separate devices they will have different IP addresses so they can all use the port 1880 without problems.

---

<div class="post-metadata">

**Author:** ![sotiriszegiannis](https://avatars.discourse-cdn.com/v4/letter/s/f04885/32.png) [@sotiriszegiannis](https://discourse.nodered.org/u/sotiriszegiannis)\
**Post date:** [8 June 2019 10:34 UTC](https://discourse.nodered.org/t/many-gateways-on-one-network/11972/5 "2019-06-08T10:34:47Z")

</div>

Hi Colin,  
by gateway i m referring to the device that hosts node red. I think you are right that since each device has a different ip i don't really need to create a separate port forward. How didn't i think of this?? Thank you!

---

<div class="post-metadata">

**Author:** ![sotiriszegiannis](https://avatars.discourse-cdn.com/v4/letter/s/f04885/32.png) [@sotiriszegiannis](https://discourse.nodered.org/u/sotiriszegiannis)\
**Post date:** [8 June 2019 10:40 UTC](https://discourse.nodered.org/t/many-gateways-on-one-network/11972/6 "2019-06-08T10:40:00Z")

</div>

Hi Colin,  
The problem with this approach is that i need to access the gateway from the outside, that is from the internet so your solution on second thought doesn't work.

---

<div class="post-metadata">

**Author:** ![Robbo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/robbo/32/4491_2.png) [@Robbo](https://discourse.nodered.org/u/Robbo)\
**Post date:** [8 June 2019 12:02 UTC](https://discourse.nodered.org/t/many-gateways-on-one-network/11972/7 "2019-06-08T12:02:18Z")

</div>

Sounds like you have multiple Node-Red systems (why?), then look at a reverse proxy like NGINX if you want to connect to them from the Internet. Also look at the guide here for securing Node-Red for Internet use.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [8 June 2019 12:47 UTC](https://discourse.nodered.org/t/many-gateways-on-one-network/11972/8 "2019-06-08T12:47:11Z")

</div>

You need to think very carefully about the security implications of opening node-red to the internet, however if you do open ports the router will allow you to specify a different external port to an internal one, so you could route port 2880 to port 1880 of device 1, port 3880 to port 1880 of device 2, etc.

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [8 June 2019 14:32 UTC](https://discourse.nodered.org/t/many-gateways-on-one-network/11972/9 "2019-06-08T14:32:52Z")

</div>

> [@sotiriszegiannis](#):
>
> i put a second gw, there doesn't seem to be a way to change the default port 1880

- You mentioned you send commands to Node.RED. It would be interesting to know what protocol you use and for what purpose? Perhaps MQTT data? Admin HTTP to Node-RED? TCP connections?

- The answers in the forum (this post many others), as well as the documentation, shows that changing the port number for Node-RED is quite easy but then you hit another issue: you would need to do some port forwarding in your router. Is this a big issue or perhaps there is some constraint that prevents you from doing so?

If the solution: change Node-RED + configure port forward in the router is the issue then you may want to [have a look on ngrok](https://ngrok.com/docs#getting-started). It comes with pros and const as usual for everything.

---

<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:** [8 June 2019 16:32 UTC](https://discourse.nodered.org/t/many-gateways-on-one-network/11972/10 "2019-06-08T16:32:04Z")

</div>

> [@mtoko](#):
>
> change the port number and then save the file

You don't even need to do that. Simply pass the PORT environment variable as you start Node-RED.

---

<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:** [8 June 2019 16:35 UTC](https://discourse.nodered.org/t/many-gateways-on-one-network/11972/11 "2019-06-08T16:35:01Z")

</div>

> [@Andrei](#):
>
> you hit another issue: you would need to do some port forwarding in your router

Only if you need to access the systems from outside the router.

There is also another option if you do need to do this. Put your microserver instances (multiple Node-RED instances in this case) behind a reverse proxy. NGINX or HAproxy for example.

In doing so, you get a number of benefits. You can get better performance, better security and you can rewrite the different ports to a single, standard port with different _paths_.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [8 June 2019 20:24 UTC](https://discourse.nodered.org/t/many-gateways-on-one-network/11972/12 "2019-06-08T20:24:06Z")

</div>

> [@TotallyInformation](#):
>
> Only if you need to access the systems from outside the router.

If he doesn't need to access them outside the router then he doesn't need to change the ports, as they will have different IP addresses.

---

<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:** [9 June 2019 10:59 UTC](https://discourse.nodered.org/t/many-gateways-on-one-network/11972/13 "2019-06-09T10:59:25Z")

</div>

> [@Colin](#):
>
> If he doesn't need to access them outside the router then he doesn't need to change the ports, as they will have different IP addresses.

You are correct of course. I was thinking about multiple instances on a single device.
