The setup:
The problem:
When accessing the raspberry from a remote location (over the Internet) via SSH, it works until the connection hangs. This occurs randomly. I can sometimes SSH it again after few minutes, and sometimes not until I restart the Raspi.
What I've tried:
debug1: Local version string SSH-2.0-OpenSSH_8.1
kex_exchange_identification: read: Connection reset by peer
Connection reset by peer
/etc/hosts.allow
and /etc/hosts.deny
=> Nothing thereiptables -L --line-number
=> Nothing there/var/log/fail2ban.log
and sudo journalctl -t sshd
=> Nothing striking theresshd_config
with no DNS
apt-get --reinstall install openssh-server openssh-client
I am running out of ideas here and no clue about what's happening. As someone encountered the same problem with SSH connection before ? Could it be a load issue on the raspberry ?
Long story short, my problem had nothing to do with a network issue and was fixed by examining the syslog.
In details:
I noticed that none of the webapps (via LAMP or MERN stacks) while up and running before the issue started, were not reachable anymore.
So I dug up the syslog with the tail -f -n X /var/log/syslog
command (replacing X with the number of lines you want to display).
I then noticed few lines mentioning a Voltage problem (sorry I did keep the exact terms). But basically it meant that my Raspi which an external HDD was plugged on did not have a strong enough power supply.
Then it looked that the HDD was unmounted and the system crashed, which explains all the issues mentioned above.
So I removed the HDD put the SD card back and ran the Raspi again while going through the syslog again and monitoring the memory with htop. It turned out that when I started both the apache and node servers, the RAM and SWAP memories were getting full repeating the same consequences mentioned above.
So finally I increased the SWAP memory by using ZRAM. Link here .
Now everything runs well but still monitoring.