Quick Fix: Stop Ubuntu 24.04 from Automatically Suspending/Sleeping

If your Ubuntu 24.04 system (especially one that started as a server install) randomly suspends or goes to sleep even though it's supposed to be a headless server, you're not alone. This guide will show you to fix right away!

há 10 meses

By Aquasp
Table of contents

If your Ubuntu 24.04 system (especially one that started as a server install) randomly suspends or goes to sleep even though it's supposed to be a headless server, you're not alone.

This seems to happen when a server installation gets partially or fully converted to a "desktop" environment at some point — even if you never intentionally installed a desktop. In my case, I installed Ubuntu Server 24.04 directly with balenaEtcher onto NVMe/SSD and I got this weird behavior (my N100 server was suspending after 15 minutes).

The Simple One-Liner Fix

Run this single command and the random suspensions stop immediately (and persist across reboots):

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

That is it!

Spread the word

Keep reading