After around 10 minutes of starting up my Raspberry Pi (Model 4b) and being SSH'd into it, it freezes. If I try to reconnect I just get connection timed out.

I've connected it to a monitor and it still works fine.

I can also ping it fine from the PC I'm trying to connect from


Pinging with 32 bytes of data:
Reply from bytes=32 time=4ms TTL=64
Reply from bytes=32 time=3ms TTL=64
Reply from bytes=32 time=4ms TTL=64
Reply from bytes=32 time=4ms TTL=64

Ping statistics for
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 3ms, Maximum = 4ms, Average = 3ms 

I've tried turning WiFi power management off but that didn't help either and I don't think that's the issue because the WiFi still works fine when I can't SSH in.

I can also still connect using VNC.

sudo service ssh status shows it as running and even if I try sudo service ssh restart and try again it still won't connect.

1 Answer 1


Here's a couple of options from man sshd_config that might help:


Sets the number of client alive messages which may be sent without sshd(8) receiving any messages back from the client. If this threshold is reached while client alive messages are being sent, sshd will disconnect the client, terminating the session. It is important to note that the use of client alive messages is very different from TCPKeepAlive. The client alive messages are sent through the encrypted channel and there‐ fore will not be spoofable. The TCP keepalive option enabled by TCPKeepAlive is spoofable. The client alive mechanism is valuable when the client or server depend on knowing when a connection has become unresponsive.

The default value is 3. If ClientAliveInterval is set to 15, and ClientAliveCountMax is left at the default, unresponsive SSH clients will be disconnected after approximately 45 seconds. Setting a zero ClientAliveCountMax disables connection termination.


Sets a timeout interval in seconds after which if no data has been received from the client, sshd(8) will send a message through the encrypted channel to request a response from the client. The default is 0, indicating that these messages will not be sent to the client.

Notice that although the default for the first one is three, the default for the last is 0 so the feature is not used. My preferred settings are:

ClientAliveInterval 120
ClientAliveCountMax 15

Although ostensibly this about not keeping clients logged in when they are non-responsive, this and TCPKeepAlive (enabled by default) should help prevent that from happening as there will always be a certain amount of actual data passed back and forth.

  • I changed those two settings, rebooted my Raspberry PI and SSH'd in. After 10 minutes again the session was unresponsive, I tried to reconnect and it timed out. The Raspberry Pi still working fine over VNC though.
    – JaAnTr
    Commented Sep 27, 2021 at 15:05

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.