Connection Lost After Some Time

It was a new card, I took it out of its box, and downloaded NOOB OS. It is a 16 GB Toshiba SD card. I don't think it is related to SD Card. Also, I have an hour left for today, then I have something planned. So, I may not be able to download and install the OS, and check for the errors again. I can do that tomorrow. What are the other options?

http://127.0.0.1:1880/ -> This couldn't load up, it was a blank page.

http://127.0.0.1:1880/ui/ -> This says:

This page isnā€™t working

127.0.0.1 didnā€™t send any data.

ERR_EMPTY_RESPONSE

Edit: I am 100% sure that the project is not working at the moment. It is like, it just can't connect to the local server somehow.

Are you sure node red is still running? How are you starting it?
If you use node-red-start then, if you have closed the terminal where you started it then you can get back to the log using node-red-log.
If you just use node-red to start it then node red will stop if you close the terminal or Ctrl-C out.

I don't think I made a mistake there. I tried to stop and start it again with the commands, but it is not responding when I try to start.

Edit: Took like a minute and then it responded.

Edit: Page is not loading properly. It is taking minutes, where it should've taken 30 seconds at worst.

What took a minute? To stop or to start? If the start at what point did it pause and what command are you using?

node-red-stop worked fast. node-red-start took like a minute to work. The page also took a few minutes. Now, it is working perfectly fine again... Really fast, with no issues at all. I don't understand... I think at some point, I cut the power to the circuit, and then connected that cable again. Only thing I can think of is this. I am not entirely sure, if I did that or not either.

Last time, I turned the power off, without shutting down (this will be the normal usage), and now, it was working perfectly fine. Again, after some time, this time around 30 mins, I got "Connection Lost". Not popping up again and again, just stays there. I don't understand... Also, I noticed that the CPU is really hot.

Edit: I have read about a guy having similar problems with high CPU usage. He says he got rid of that by deleting files that he is not using, located in the lib folder. I am looking at the Export option's Library tab to see the things I use, but it is not loading up. Is there a way to see which libraries I am not using?

This is not a good idea, just pulling the plug is a good way to corrupt your SD card

Is there a way to shut Pi down from dashboard?

I used "node-red-stop", then "node-red-start", and this is what I saw in the logs:

> 14 Jul 10:52:39 - [warn] Error loading credentials: SyntaxError: Unexpected token ļæ½ in JSON at position 0
> 14 Jul 10:52:39 - [warn] Error loading flows: Error: Failed to decrypt credentials
> 14 Jul 10:52:39 - [info] Starting flows
> 14 Jul 10:52:39 - [info] Started flows

And this warning on the Node-Red page:

> Credentials could not be decrypted
> 
> The flow credential file is encrypted, but the project's encryption key is missing or invalid.
> 
> The flow credential file will be reset on the next deployment. Any existing flow credentials will be cleared.

I think you have been corrupting your card by switching the power off, don't do that. To shutdown cleanly from node-red you can use an exec node with the command sudo shutdown -h now.
It might be a good idea to re-flash the card and start again, after making sure you have backed up what you need of course.
In practice the occasional power fail in use will usuallynot do any harm but if you keep doing it then you will get issues.

Thanks. I'll add the exec node. For now, I don't have any other SD cards. I'll get one soon, probably today.

What about the other thing? If I could see which libraries I am using, and delete the rest, that might help. Maybe this alone could solve it.

Edit: By the way, how can I use that exec command to shutdown after 10 seconds? Not sure if shutting down fast would be a problem, or not. If it is not, that is good. If it is, how can I make it 10 seconds?

What other thing and what do you mean by libraries?

You could use a Delay node to delay the message from the button, or you can lookup the shutdown command to see how to tell it to wait a bit (run man shutdown in a terminal). I don't see what difference waiting a bit will make though.
However you might want to use a Notification node in OK/Cancel mode to show a popup asking for confirmation, in case you accidentally touch the shutdown button.

It is most unlikely you will have damaged the card, so you could just reflash it.

Here is a better way to show what I am trying to say:

2nd answer is the solution for this guy. He deleted the stuff that he doesn't use. I don't know where to see which libraries I am using, and which I am not.

Also, that notification idea is great! Thanks!

Oh, you mean which nodes you are not using. In the Manage Palette menu on the Installed tab it shows you all the nodes you have installed and provides an Uninstall button for those which are not in use.
If you have been corrupting your card then there is no point trying to analyse any other problems until you have sorted that.

He says: " It was related to the amount of libraries that are in the folder /home/pi/.node-red/lib/.". Does the method you said removes files in this path?

Look in that folder and see what you have there. I can't do that for you.

Going to try it with a new SD card now. I won't update Node-Red this time. When I changed the node for temperature sensor, after a short time, I also updated Node-Red. It was working fine between these moments. So, I will try to see what happens without upgrading Node-Red.

If you can recreate this scenario with new SD card, this seems a bit similar to what I saw in my case where the flows file went poof once. I was not able to recreate the issue. I was able to confirm my SD card was not at fault... did an explicit (low) level format on card... no something you want to do a lot, shortens the life of the card. I also cloned the original card, and the clone did not exhibit the behavior, so what not a simple file system corruption issue, and did not seem to be a media issue.