Score:1

Ubuntu 20.04 server suspends or goes to sleep after a certain period of time, causing ssh to time out

rs flag

Problem

I currently have my own Ubuntu server set up at home for development. However, when I try to ssh again after a certain period of time (about 20-30 minutes), it times out. Even after trying the ping command, no packets came back. If I do a physical reboot, ssh connection is possible without any problem.

What I want to solve

In order to be able to always ssh from another client PC even after a certain period of time has passed, I need to make the Ubuntu server sleep or suspend. Suspend? I'd like to know how to set it up so that it doesn't go into sleep/suspend mode.

Things I've tried

  1. sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target.

I disabled suspend and hibernate with this command and tried to reboot, but the result was the same.

  1. I found that for some reason, despite being an Ubuntu Server, I was able to change the gnome settings so I tried to change the settings with the following command.
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type nothing
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-timeout 0
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type nothing
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 0

However, the result was the same here.

  1. I came across this question Ubuntu 20.04 keeps goes to sleep and tried it out but it did not work.

  2. I also changed the settings in the /etc/gdm3/greeter.dconf-defaults file as follows but there was no change even after rebooting after changing.

# Automatic suspend
# =================
[org/gnome/settings-daemon/plugins/power]
# - Time inactive in seconds before suspending with AC power.
# 1200=20 minutes, 0=never
# sleep-inactive-ac-timeout=1200
sleep-inactive-ac-timeout=0
# - What to do after sleep-inactive-ac-timeout
# 'blank', 'suspend', 'shutdown', 'hibernate', 'interactive' or 'nothing'.
# sleep-inactive-ac-type='suspend'
# - As above but when on battery
# sleep-inactive-battery-timeout=1200
sleep-inactive-battery-timeout=0
# sleep-inactive-battery-type='suspend'

System configuration

  • Ubuntu Server 20.04.2 LTS (GNU/Linux 5.4.0-80-generic x86_64)
  • AMD Ryzen 5950
  • AsRock Taichi X570

I would appreciate it if you could help me with a solution. Thank you very much for your help.

in flag
Ubuntu Server does not have any power management features out of the box, as servers are (generally) not supposed to suspend or otherwise become unavailable. Have you confirmed the machine is entering suspend mode? Have you installed a UI on top of the server? Have you confirmed that the assigned network addresses are consistent?
hphex avatar
rs flag
@matigo Thank you for your comment. > Have you installed a UI on top of the server? I do not think I have installed UI however, it might have happened since there is a gnome setting.
hphex avatar
rs flag
@matigo As for the network environment, I am sure that the server has static IP since I use VPN via tailscale.
in flag
If the machine is going into suspend (or some other low-power mode), then there should be something in the logs that states as much. You should see something in `/var/log/syslog`. This would also be the place to check for other system errors or, as I've seen from time to time, network-related issues that can take an interface offline ...
Score:0
rs flag

SOLVED:

I had installed xcape which is written in my dotfiles for another Ubuntu desktop env.

After running this command from this post, removed all desktop related libraries and never went to sleep mode.

Remove GUI on Ubuntu Server

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.