# Connect to RPI via SSH and keep Node-Red alive

**URL:** <https://discourse.nodered.org/t/connect-to-rpi-via-ssh-and-keep-node-red-alive/37139>\
**Category:** General\
**Created:** [7 December 2020 16:19 UTC](https://discourse.nodered.org/t/connect-to-rpi-via-ssh-and-keep-node-red-alive/37139 "2020-12-07T16:19:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sidr](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@Sidr](https://discourse.nodered.org/u/Sidr)\
**Post date:** [7 December 2020 16:19 UTC](https://discourse.nodered.org/t/connect-to-rpi-via-ssh-and-keep-node-red-alive/37139/1 "2020-12-07T16:19:17Z")

</div>

Hello,

I am using a RPi 4 to monitor the air quality of rooms. I have built a Node-red flow that processes and sends the output via MQTT. I start the node-red flow by SSH. The problem is that although the RPi is connected to WiFi the MQTT connection is disturbed as soon as I change the WiFi or close the terminal in my Laptop.

Is there is way to activate the Node-red flow once via SSH and then keep the Node-red flow running even after closing the terminal in laptop.

Thank you very much for your replies.

Regards,

Sid

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [7 December 2020 16:27 UTC](https://discourse.nodered.org/t/connect-to-rpi-via-ssh-and-keep-node-red-alive/37139/2 "2020-12-07T16:27:53Z")

</div>

Hi @Sidr

how have you installed Node-RED on the Pi?

If you've used our [install script](https://nodered.org/docs/getting-started/raspberrypi) then Node-RED will be setup to run as a service and you can then configure it to auto start on boot: [https://nodered.org/docs/getting-started/raspberrypi#autostart-on-boot](https://nodered.org/docs/getting-started/raspberrypi#autostart-on-boot)

---

<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:** [7 December 2020 20:55 UTC](https://discourse.nodered.org/t/connect-to-rpi-via-ssh-and-keep-node-red-alive/37139/3 "2020-12-07T20:55:52Z")

</div>

> [@Sidr](#):
>
> Is there is way to activate the Node-red flow once via SSH and then keep the Node-red flow running even after closing the terminal in laptop.

Nicks information on running as a service is best.

But you _can_ also run it as you've outlined simply by installing TMUX, SCREEN or BYOBU. Start a session when you log in, start NR in that session then you can kill your SSH connection. Next SSH login, you can reconnect to the still running session. You can also configure to auto-reconnect. Personally, I prefer Byobu but any of the 3 will work.

This also has the advantage that you can leave other long-running commands going. Especially useful if you are mobile or have a unreliable connection.

---

<div class="post-metadata">

**Author:** ![Sidr](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@Sidr](https://discourse.nodered.org/u/Sidr)\
**Post date:** [10 December 2020 12:46 UTC](https://discourse.nodered.org/t/connect-to-rpi-via-ssh-and-keep-node-red-alive/37139/4 "2020-12-10T12:46:28Z")

</div>

Thank you very much for your replies. It worked. I enabled to autostart Node-red on boot

---

<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:** [8 February 2021 12:46 UTC](https://discourse.nodered.org/t/connect-to-rpi-via-ssh-and-keep-node-red-alive/37139/5 "2021-02-08T12:46:46Z")

</div>

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