How to fix E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable) in APT

APTBEGINNERMEDIUMUpdated Dec 29, 2025· 160 views

This error occurs when the apt package manager cannot acquire the dpkg lock file because another package management operation is already in progress. The system's package manager can only run one operation at a time, and concurrent attempts will fail with this lock error.

Quick fix

Fixes E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)

sudo lsof /var/lib/dpkg/lock-frontend
  1. Wait for background operations to complete
  2. Identify the process holding the lock
  3. Terminate the blocking process (if safe)
  4. Remove stale lock files (last resort)
apt — error
sudo lsof /var/lib/dpkg/lock-frontend
E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)

What this error means

The 'Could not get lock' error indicates that the dpkg package management system is busy performing another operation. When apt or apt-get attempts to install, update, or remove packages, it creates a lock file at /var/lib/dpkg/lock-frontend to ensure only one package operation runs at a time. This prevents data corruption and conflicts. If you attempt to run an apt command while another is in progress (or if a previous operation didn't release the lock), apt rejects the request with error code 11 (Resource temporarily unavailable), which means the resource is currently locked.

Typical symptoms

  • apt install, apt update, or apt upgrade commands fail immediately
  • apt-get commands return the lock-frontend error
  • Installing packages via GUI package managers (like GNOME Software) fails
  • System update notifications fail to process updates
  • Automated background updates appear to hang or fail

Common causes

  1. Unattended security upgrades are running in the background (common on Ubuntu)
  2. Another terminal has an active apt or apt-get command running
  3. The Software Update daemon is installing updates
  4. A previous apt operation crashed or hung, leaving the lock file in place
  5. DPKG is reconfiguring packages from a previous failed installation

How to fix "E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)"

1Wait for background operations to complete

The most common cause is an unattended upgrade running in the background. Wait 5-15 minutes for the operation to finish naturally. You can check if upgrades are running:

bash
sudo lsof /var/lib/dpkg/lock-frontend

If you see 'unattended-upg' in the output, an automatic upgrade is running. Let it finish before proceeding.

2Identify the process holding the lock

Check which process is holding the lock using lsof or ps:

bash
# Check which process holds the lock
sudo lsof /var/lib/dpkg/lock-frontend

# Or search for apt/dpkg processes
ps aux | grep -E 'apt|dpkg'

Note the PID and command. If it's 'unattended-upgr', wait for it to finish. If it's another process that shouldn't be running, proceed to the next step.

3Terminate the blocking process (if safe)

If the lock is held by a process that's stuck or shouldn't be running (not unattended-upgrades), you can terminate it:

bash
# Replace PID with the actual process ID from step 2
sudo kill -9 PID

Wait a few seconds after killing the process, then try your apt command again. Do NOT kill unattended-upgrades unless you're certain updates are truly stuck.

4Remove stale lock files (last resort)

If no processes are using dpkg but the lock file persists, you can manually remove it:

bash
# Remove lock files
sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock
sudo rm /var/lib/dpkg/lock-frontend

# Reconfigure dpkg
sudo dpkg --configure -a

After removing lock files, reconfigure dpkg and try your apt command again. This should only be done if other methods fail, as it risks package inconsistency if done incorrectly.

5Reboot if problems persist

If the lock remains stuck after all steps, reboot the system:

bash
sudo reboot

After reboot, the lock files will be cleared and background upgrades will resume cleanly. This is the safest option if you're unsure about killing processes.

Advanced notes

On Ubuntu systems, unattended-upgrades runs automatically by default, typically scheduling updates for early morning hours. If you frequently encounter this error, consider disabling unattended upgrades (sudo apt remove unattended-upgrades) or configuring its schedule in /etc/apt/apt.conf.d/50unattended-upgrades. The dpkg lock mechanism is crucial for system stability—never force remove lock files if a package manager process is actively running. On Debian systems, the timing of APT-acquire and unattended-upgrades can conflict; consider installing needrestart to handle automatic daemon restart after updates without locking apt. When scripting apt operations in automation (Docker, CI/CD, etc.), always wait for or kill existing apt processes before starting your own to avoid lock contention.

Frequently asked questions

What does "E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource" mean?
The 'Could not get lock' error indicates that the dpkg package management system is busy performing another operation. When apt or apt-get attempts to install, update, or remove packages, it creates a lock file at /var/lib/dpkg/lock-frontend to ensure only one package operation runs at a time. This prevents data corruption and conflicts.
How do I fix "E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource"?
This error occurs when the apt package manager cannot acquire the dpkg lock file because another package management operation is already in progress. The system's package manager can only run one operation at a time, and concurrent attempts will fail with this lock error.
What causes "E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource"?
Unattended security upgrades are running in the background (common on Ubuntu) Another terminal has an active apt or apt-get command running The Software Update daemon is installing updates
Is the "E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading