Connect to RPI via SSH and keep Node-Red alive

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

Hi @Sidr

how have you installed Node-RED on the Pi?

If you've used our install script 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

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.

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