Skip to content

/errors/apt/could-not-get-lock

apt: Could not get lock /var/lib/dpkg/lock-frontend

The commands on this page have not been executed by our verification runner yet.updated 2026-10-20
tool
apt
exit code
100
versions
Debian 10+, Ubuntu 18.04+
os
linux

apt and dpkg take a lock on /var/lib/dpkg/lock-frontend (and /var/lib/dpkg/lock) so that only one process changes the package database at a time. A second process stops with:

text
E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 1234 (unattended-upgr)
N: Be aware that removing the lock file is not a solution and may break your system.
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?

The message names the process. Most often it is unattended-upgrades, which installs security updates shortly after boot.

Find the process and wait

bash
sudo lsof /var/lib/dpkg/lock-frontend
ps -o pid,etime,cmd -C apt,apt-get,dpkg,unattended-upgr

In scripts and CI, let apt wait for the lock instead of failing:

bash
sudo apt-get -o DPkg::Lock::Timeout=300 install -y curl

If dpkg was interrupted

When nothing holds the lock but apt says dpkg was interrupted, finish the pending configuration:

bash
sudo dpkg --configure -a
sudo apt-get -f install

Sources