Your Linux Laptop Won't Suspend? Here's What You Can Do

When a Linux laptop refuses to sleep, the first instinct should be to check what's stopping it. Here's a troubleshoot guide for your reference.
Warp Terminal

You close the lid and the laptop keeps running. Or you leave it alone for an hour and it never goes to sleep. Often nothing is broken. The cause is a program that asked systemd to hold off sleep.

That request is called an inhibitor lock. In this article, you'll list the locks on your system, read what each one blocks, tell a lock that stops a suspend from one that only delays it, and close the program that holds it.

Every command here works on any distribution that uses systemd. I ran them on an Ubuntu 26.04 desktop virtual machine with GNOME, which ships systemd 259.

What an inhibitor lock is

A program takes an inhibitor lock from systemd-logind, the systemd service that handles sleep, shutdown and the power keys. The lock says what the program wants to hold back, why, and for how long.

A backup tool might hold a lock while it copies files, so the laptop doesn't suspend halfway through. A video player might hold one so the screen doesn't go idle during a movie. When the program exits, its lock goes away with it.

The problem starts when a program holds a lock it no longer needs, or holds a stronger lock than it should.

List every inhibitor lock

The systemd-inhibit command lists the active locks. It needs no root.

systemd-inhibit --list

To have a lock to clear later in this article, I first started a stand-in backup job wrapped in systemd-inhibit. It holds a block lock on sleep and shows up as "Backup script". Everything else in the list below came from the system itself.

WHO                          UID  USER     PID  COMM            WHAT                                                     WHY                                                         MODE
Backup script                0    root     4952 systemd-inhibit sleep                                                    Copying files to the NAS                                    block
ModemManager                 0    root     1322 ModemManager    sleep                                                    ModemManager needs to reset devices                         delay
NetworkManager               0    root     1196 NetworkManager  sleep                                                    NetworkManager needs to turn off networks                   delay
Realtime Kit                 0    root     1497 rtkit-daemon    sleep                                                    Demote realtime scheduling and stop canary.                 delay
UPower                       0    root     2006 upowerd         sleep                                                    Pause device polling                                        delay
Unattended Upgrades Shutdown 0    root     1365 unattended-upgr shutdown                                                 Stop ongoing upgrades or perform upgrades before shutdown   delay
GNOME Shell                  1000 demouser 3538 gnome-shell     sleep                                                    GNOME needs to lock the screen                              delay
GNOME Shell                  1000 demouser 3538 gnome-shell     sleep                                                    GNOME needs to save screen time data                        delay
demouser                     1000 demouser 3683 gsd-power       handle-lid-switch                                        External monitor attached or configuration changed recently block
demouser                     1000 demouser 3682 gsd-media-keys  handle-power-key:handle-suspend-key:handle-hibernate-key GNOME handling keypresses                                   block
demouser                     1000 demouser 3682 gsd-media-keys  sleep                                                    GNOME handling keypresses                                   delay
demouser                     1000 demouser 3683 gsd-power       sleep                                                    GNOME needs to lock the screen                              delay

12 inhibitors listed.
systemd-inhibit --list showing the twelve inhibitor locks on a GNOME desktop

Here is what each column tells you.

  • WHO is the name the program gave itself.
  • PID and COMM are the process that holds the lock. You'll use the PID later to find and close it.
  • WHAT is what the lock holds back.
  • WHY is the reason the program gave.
  • MODE says whether the lock blocks the action or only delays it.

Read the WHAT column

The WHAT column tells you which problem a lock can cause. These are the values that matter for suspend and idle.

  • sleep covers suspend and hibernate. A block lock here stops the laptop from suspending at all.
  • idle stops the system from treating your session as idle. That blocks anything that waits for idle, such as automatic suspend after a timeout. This is the usual reason a laptop ignores its idle timer.
  • handle-lid-switch takes over the lid. While a program holds it, systemd doesn't act when you close the lid.
  • handle-power-key, handle-suspend-key and handle-hibernate-key do the same for those keys. Desktops often hold them because they handle the keys themselves, so these locks are normal.
  • shutdown covers power off and reboot.

A lock can list more than one value, separated by colons, such as sleep:shutdown.

Tell a block lock from a delay lock

The MODE column has two values.

A block lock stops the action for as long as the program holds it. Only a privileged user can override it. This is the kind that leaves a laptop awake.

A delay lock only holds the action back for a short time, so the program can finish something first. A chat app might save its state before the laptop sleeps. When the time runs out, systemd suspends anyway. The limit is InhibitDelayMaxSec= in /etc/systemd/logind.conf. The commented default in that file is 5 seconds.

Delay locks exist only for sleep and shutdown. When I tried to take one for idle, systemd refused it.

systemd-inhibit --what=idle --mode=delay --who=test --why=test true
Failed to inhibit: Delay inhibitors only supported for shutdown and sleep

Most of the list above is delay locks from GNOME, NetworkManager, ModemManager, Realtime Kit and UPower. They rarely cause trouble. When your laptop won't sleep, look for a block lock on sleep, idle or handle-lid-switch.

Show only the block locks

On a desktop, the list can run to a dozen lines. Add --mode=block to see only the locks that can stop an action.

systemd-inhibit --list --mode=block
WHO           UID  USER     PID  COMM            WHAT                                                     WHY                                                         MODE
Backup script 0    root     4952 systemd-inhibit sleep                                                    Copying files to the NAS                                    block
demouser      1000 demouser 3683 gsd-power       handle-lid-switch                                        External monitor attached or configuration changed recently block
demouser      1000 demouser 3682 gsd-media-keys  handle-power-key:handle-suspend-key:handle-hibernate-key GNOME handling keypresses                                   block

3 inhibitors listed.
systemd-inhibit --list --mode=block showing three block locks

Here is what each of the three does.

Backup script is the stand-in job. It holds a block lock on sleep, so the laptop can't suspend while it runs.

gsd-power is GNOME's power manager. It holds a block lock on handle-lid-switch. Its reason reads "External monitor attached or configuration changed recently". GNOME takes this lock while an external monitor is attached and for a short time after the display setup changes, so the laptop keeps running when you close the lid. If your laptop stays on when you close the lid, check for this lock first.

gsd-media-keys is GNOME's key handler. It blocks systemd from acting on the power, suspend and hibernate keys because GNOME handles those keys itself. This lock is normal on a GNOME desktop.

You might expect --what=sleep to narrow the list the same way. On systemd 259 it doesn't. systemd-inhibit --list --what=idle printed every lock on my test machine, including the ones on sleep and shutdown. The man page doesn't say that --list filters by WHAT, so read the WHAT column yourself.

Find and close the program that holds a block lock

Take the PID from the lock you want to clear. Look at the full command line of that process.

ps -p 4952 -o pid,comm,args
    PID COMMAND         COMMAND
   4952 systemd-inhibit systemd-inhibit --what=sleep --who=Backup script --why=Copying files to the NAS --mode=block sleep 300

In this case the lock comes from a script that wraps a job in systemd-inhibit, so the command line shows the job it's running. When COMM shows a normal application, such as a browser or a media player, that application holds the lock itself.

The cleanest fix is to close the program the way you normally would, or to change its own power setting. Some programs have their own setting that keeps the system awake. If the program is stuck, end it with its PID.

sudo kill 4952

List the locks again to confirm the lock is gone.

systemd-inhibit --list --mode=block
WHO      UID  USER     PID  COMM           WHAT                                                     WHY                                                         MODE
demouser 1000 demouser 3683 gsd-power      handle-lid-switch                                        External monitor attached or configuration changed recently block
demouser 1000 demouser 3682 gsd-media-keys handle-power-key:handle-suspend-key:handle-hibernate-key GNOME handling keypresses                                   block

2 inhibitors listed.
The Backup script lock is gone after its process was ended

If the lock belongs to a system service, stop that service with systemctl instead of killing the process, so it doesn't start again and take a new lock.

Check whether a lock is really the cause

Inhibitor locks only apply when a suspend goes through systemd. That covers systemctl suspend, the suspend option in your desktop's menu, the lid and the idle timer.

To find out whether a lock is what keeps your laptop awake, suspend once with the lock checks turned off.

sudo systemctl suspend --check-inhibitors=no

If the laptop suspends now, a lock was the cause, and the steps above will find it. If it still doesn't suspend, the cause is outside systemd's locks. The kernel log from the failed attempt is the next place to look.

Conclusion

When a Linux laptop refuses to sleep, start with systemd-inhibit --list. Look for a block lock on sleep, idle or handle-lid-switch, find its process from the PID, and close that program or change its power setting. A delay lock only holds the suspend for a few seconds and is rarely the problem.

This is just one of the many systemd tools you can use for troubleshooting your Linux system.

New to Linux? These 4 systemd Tools Help You Fix Common Issues
Stop guessing, start investigating. Here are 4 systemd tools that make Linux troubleshooting easy.

Next time your laptop stays awake with the lid closed, run the list before you start digging through power settings.

✍️
Christopher Smith has worked in IT operations for 15 years, more than ten of them in enterprise endpoint management. He builds ET Ducky, a remote monitoring and management platform for Windows and Linux.

If this helped you, consider supporting It's FOSS

It's FOSS has been helping people use Linux for the past 14 years. Help us stay independent from big tech. Become a Plus member, enjoy ad-free reading and get 5 eBooks.

Plus yearly

Ad-free, FREE ebooks

Join yearly

Buy us a coffee

Any amount, no commitment

Support on Ko-fi
About the author
Community

Community

Written by a community member, a reader who is not part of the It's FOSS writing team. The views and opinions expressed are those of the authors and do not necessarily reflect that of It's FOSS.

Become a Better Linux User

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world

itsfoss happy penguin

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.