I've got a Raspberry Pi 3B+ running Raspbian Stretch that I've been using successfully for months to run my Home Assistant instance. I've been connecting to it using SSH and it's always worked fine. A few weeks ago it started acting up though, for no apparent reason, first my Home Assistant Docker instance went down, then it started to become unresponsive to SSH. I've restarted it multiple times and it's always responding to ping (the IP is reserved in the router) but most of the time I can't access it.

The respons I get is first Connection refused (maybe this is while its booting up), then after a while it works fine, then all of a sudden (after a few minutes) it freezes and I get Connection reset by peer. Once this happens the only way to get another response seems to be to restart it.

Sometimes it actually doesn't freeze, I can use it for long periods of time, but I've noticed that I can never have multiple console windows open with ssh (used to work before though), the first one might succeed but the second one will always get denied. Also closing the connection with exit and trying to reopen it doesn't work either.

Are there any logs I can check to investigate this further?

EDIT: I've also noticed that a lot of the basic commands I run seems to fail and throw errors like:

Failed to read server status: Connection timed out for something as simple as systemctl status

Failed to list units: Failed to activate service 'org.freedesktop.systemd1': timed out for various commands.

error during connect: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.38/containers/json: read unix @->/var/run/docker.sock: read: connection reset by peer sometimes for docker ps

EDIT 2: Could be memory related? top enter image description here

EDIT 3: I've also noticed that the shell Zsh never remembers my previous commands when I log in (seems to only remember the commands from a few days ago) and the plugin Oh-My-Zsh always needs to be updated, even if I updated it just minutes before. Groundhog day, anyone :/

  • How big is your SD card? It might need to be replaced. Try booting up the Pi connected to a monitor, it might show some useful things there.
    – user96931
    Dec 16, 2019 at 21:05
  • It's 16gb, running df shows 88% usage on /dev/root, which is the same as it's been for as long as I have monitored the disk usage. I can't get it to work with a monitor. Always used it headless, was assuming it was plug-and-play, but my monitor only says no signal.
    – Martin
    Dec 16, 2019 at 21:20
  • 1
    Trying to diagnose a problem using ssh is difficult. There are (at least) 3 components, the originating system, network/router and Pi - any of these can cause problems and only a full restart of ALL can give you a fresh system to debug. You should try a direct keyboard/screen for debugging.
    – Milliways
    Dec 17, 2019 at 1:28
  • 2
    Most of us would restore from a backup to a fresh SD Card to test whether a corrupted OS or faulty SD Card is the problem. PS DO NOT paste images - post TEXT.
    – Milliways
    Dec 17, 2019 at 1:29
  • 1
    If a new SD Card solve your problem please make it an answer and accept it after two days. Only accepting an answer will finish a question and it will not pop up again year for year. You can try to completely clear the SD Card with sudo dd if=/dev/zero of=/dev/sdb bs=4M conv=fsync (takes a long time until no space left over exit error). Then repartition it. But I would use it with caution, not using it for "critical" issues.
    – Ingo
    Dec 18, 2019 at 9:21

1 Answer 1


As pointed out by @Milliways, the SD seemed to be the problem. I changed to another one (by making a backup using the terminal and restoring it with Etcher) and it's been running flawlessly now for 24h straight. I've also read that SD cards can fail in this manner because of sudden power interruptions (i.e. pulling out the power cord), which TBH I've done quite a few times :/ Will use sudo shutdown -h now in the future!

  • 1
    Follow-up: Can confirm that the SD card did the trick. Been running like clockwork for 2 months now. The old SD card seems to be toast though, can't even format it properly.
    – Martin
    Feb 11, 2020 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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