My setup is a RaspberryPi4 with SSD (Kingston 120GB) as boot drive. It has also a regular HDD connected to it. Both hard drives are connected to a USB dock via 3.0 USB. The dock has also a power supply so no energy problems should arise. Connected via ethernet to router. SSH enabled. I have setup an apache server with Nextcloud (which it hasn't been started to be used because of the problems stated below) and also is setup as a client for a Wireguard VPN.

The problem is that when I turn on the RPi4 I can ssh to it without any issues, but if I leave it powered ON overnight, the next day I try to connect to it, the ssh console (or whatever I try to use) just freezes or behaves abnormally.

One day I could log in but I could not run any "complicated" commands (just cd and ls were working) and trying to run commands like sudo nano just left my ssh window frozen, no output. And today for example it just does not connect. I can ping the RPi4, but ssh refuses to let me in. It just freezes after inputting the password, no output from the RPi4.

I don't know what might be happening, this is the first time something like this happens to me, but I think it could be related to the USB dock with the hard drives in it? How can I know what is happening?


There are many possibilities, from a heavy load that is running to a faulty SD card.

First thing is to examine the logs. Does the syslog give any hints? Errors/warnings? If so: this is probably the first thing you need to correct.

Next would be the filesystems. Any at 100%? What about swap?

Can you run a vmstat 10 > /tmp/vmstat until it crashes? that would give some information about whether the system is extremely loaded. If the vmstat shows extreme load, you might try


while : ; do
    top -bn1 >>/tmp/top
    sleep 10

(or put the output on some external drive if your sdcard is relatively full). That will give you an idea of the process that causes the load.

  • I'm going to leave the script running tonight to see if tomorrow i still have the same issues. Just a quick note, in my setup I point out that I do not have an sd card to boot, but a SSD instead, don't know if that may be the issue or not. I even also increased the swap size to 2GB so the Raspberry had more space for programs to run – RabidTunes May 4 at 20:08
  • So I have been running it for 2 days and so far no issues... also no weird things on the logs so I don't know... if it does not start failing i think i will mark your answer as the one that "solved" the issue... what a weird thing... – RabidTunes May 6 at 19:55

It could be that there is a heavy memory workload, so there is a lot of swapping. I had similiar issues when I executed too many programs at once.

Try disabling swapfile, then the heavy memory application should be killed more likely and ssh should be still available.

Try this day via sudo swapoff -a This disables swap until the next reboot.

  • The thing is that I do not really have installed that many programs. I mean, there's only wireguard and apache server. I'm going to use the script that @Ljm_Dullaart left on their answer and leave it overnight so i can see which processes were taking the most resources from my Pi. I might have to consider more lightweight options for the pi tho... – RabidTunes May 4 at 20:22
  • I don't really think it might be a swap issue as I have an SSD and I have allocated lots of swap space onto the SSD. Also been checking with top command the most consuming processes and no one had more than 0.5% of the RAM in use... so I don't know – RabidTunes May 6 at 19:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.