In summary, I run a node-red server on a raspberry pi (zero w in desktop OS), almost everything works perfectly.
My only problem is the internet at my house, sometimes it goes down and reconnects. After that happens and the rasp manages to reconnect to the internet, but the server apparently remains offline.
I can even access the page of the nodes through the raspberry (using the monitor, since I use Desktop OS), but it no longer responds to commands that I send from outside and I can no longer access the page of the nodes by the IP address.
So, every time this happens I need to restart my raspberry to get it back to normal.
I thought about restart raspberry if lost connection to the internet, but I don't know how I could do that.
Sorry for the confusion. I found out more about it. In fact, what was offline was not the node red server, but the internet connection of the raspberry pi itself.
How can I make the raspberry test the internet every 5 minutes for example, in case it is offline, it does a reboot?
I would first try and understand what is failing, it should automatically reconnect. Do you mean that the pi cannot access the internet (can you browse to google.com on the pi?) Or do you mean you cannot access the pi from the internet?