How to fix E: Could not get lock /var/cache/apt/archives/lock - open (11: Resource temporarily unavailable) in APT

APTBEGINNERMEDIUMUpdated Sep 9, 2026· 324 views

This error occurs when another apt process is actively accessing the package cache, or a previous operation left a stale lock file. The lock prevents multiple package operations from corrupting the cache simultaneously. Waiting for background processes or removing stale locks will resolve this issue.

Quick fix

Fixes E: Could not get lock /var/cache/apt/archives/lock - open (11: Resource temporarily unavailable)

sudo lsof /var/cache/apt/archives/lock
  1. Wait for background apt processes to complete
  2. Wait for unattended upgrades if present
  3. Check for stuck processes and terminate them
  4. Remove stale lock files
apt — error
sudo lsof /var/cache/apt/archives/lock
E: Could not get lock /var/cache/apt/archives/lock - open (11: Resource temporarily unavailable)

What this error means

The apt package manager uses lock files to prevent concurrent access to critical package cache directories. The lock at /var/cache/apt/archives/lock protects the package archive cache from being read or written by multiple processes simultaneously. When apt cannot obtain this lock (error code 11 means "Resource temporarily unavailable"), it indicates either another apt process is actively running, unattended system updates are in progress, or a previous operation was interrupted and left a stale lock file behind. Unlike the dpkg lock which protects the entire package database, this specific lock protects just the downloaded package archives cache.

Typical symptoms

  • apt or apt-get commands fail when trying to install or update packages
  • Error explicitly mentions /var/cache/apt/archives/lock
  • Running apt commands twice in quick succession causes this error
  • Automated system updates (unattended-upgrades) block manual apt operations
  • Docker builds fail during the apt update or install phase

Common causes

  1. Another apt process is currently running in the background (most common)
  2. Unattended security updates are in progress (on most Ubuntu/Debian systems)
  3. A previous apt operation was interrupted and left a stale lock file
  4. Multiple apt commands were run simultaneously from different terminals or scripts
  5. Docker build or system automated task is accessing apt while you try to use it
  6. Software Center or GUI package manager is running

How to fix "E: Could not get lock /var/cache/apt/archives/lock - open (11: Resource temporarily unavailable)"

1Wait for background apt processes to complete

Before trying anything else, wait 1-2 minutes for any running apt or unattended-upgrade processes to finish:

bash
sudo lsof /var/cache/apt/archives/lock

This command shows which processes currently hold the lock. Common ones are:
- apt, apt-get: Another apt operation is running
- unattended-upgr: Automatic security updates are in progress
- apt-daily-upgrade: Scheduled system updates

If you see output with these processes, simply wait. The lock will be released automatically once they complete.

2Wait for unattended upgrades if present

On Ubuntu and Debian systems, unattended-upgrades runs automatically (usually daily). Check its status:

bash
sudo systemctl status apt-daily-upgrade.service

If it shows "active (running)", your system is performing security updates. Wait 5-30 minutes depending on how many packages need updating:

bash
sudo systemctl status apt-daily.service

Do NOT interrupt or kill these processes—they perform critical security updates. Once they finish, the lock will be released and apt will work normally.

3Check for stuck processes and terminate them

If background processes appear stuck and haven't released the lock after waiting, use fuser to safely terminate them:

bash
sudo fuser -vik -TERM /var/cache/apt/archives/lock

This command:
- -v: Verbose, shows which processes are killed
- -i: Interactive (asks before killing, add -k to skip confirmation)
- -TERM: Uses graceful termination first

If this doesn't work, try with -KILL:

bash
sudo fuser -vik -KILL /var/cache/apt/archives/lock

After terminating processes, you may need to repair dpkg:

bash
sudo dpkg --configure -a
4Remove stale lock files

If the lock persists after waiting and terminating processes, remove the stale lock file:

bash
sudo rm /var/cache/apt/archives/lock

Then also remove related locks to ensure a clean state:

bash
sudo rm -f /var/lib/apt/lists/lock
sudo rm -f /var/lib/dpkg/lock
sudo rm -f /var/lib/dpkg/lock-frontend

Reconfigure dpkg to ensure it's in a good state:

bash
sudo dpkg --configure -a

Now try your apt command again:

bash
sudo apt update
5Fix apt cache if corruption occurred

If removing lock files causes apt to complain about cache corruption, clean and rebuild the cache:

bash
sudo apt clean
sudo apt autoclean

Then update the package list:

bash
sudo apt update

If apt still complains, force a full cache refresh:

bash
sudo apt update --fix-missing
6Reboot if problems persist

If you've tried all the above steps and still cannot use apt, a reboot will clear all locks and reset apt state:

bash
sudo reboot

After rebooting, apt should work normally. The lock files will be recreated as needed.

Advanced notes

The lock file at /var/cache/apt/archives/lock is separate from /var/lib/dpkg/lock and /var/lib/apt/lists/lock. Each protects different parts of the package management system: /var/cache/apt/archives/lock guards the downloaded .deb package files, /var/lib/apt/lists/lock protects the package index files (what apt knows is available), and /var/lib/dpkg/lock protects the actual package database. In Docker, this error is common when apt operations run during image builds while the package cache hasn't been cleared. The fix is to use apt-get clean before new RUN commands. On systems with unattended-upgrades, you can check scheduled times with grep "APT::Periodic" /etc/apt/apt.conf.d/*. Some users disable unattended-upgrades if it conflicts with their schedule by creating /etc/apt/apt.conf.d/99disable-unattended-upgrades with content APT::Periodic::Unattended-Upgrade "0";. However, this trades automatic security updates for manual control—ensure you remember to apply security updates manually.

Frequently asked questions

What does "E: Could not get lock /var/cache/apt/archives/lock - open (11: Resourc" mean?
The apt package manager uses lock files to prevent concurrent access to critical package cache directories. The lock at /var/cache/apt/archives/lock protects the package archive cache from being read or written by multiple processes simultaneously. When apt cannot obtain this lock (error code 11 means "Resource temporarily unavailable"), it indicates either another apt process is actively running, unattended system updates are in progress, or a previous operation was interrupted and left a stale lock file behind.
How do I fix "E: Could not get lock /var/cache/apt/archives/lock - open (11: Resourc"?
This error occurs when another apt process is actively accessing the package cache, or a previous operation left a stale lock file. The lock prevents multiple package operations from corrupting the cache simultaneously. Waiting for background processes or removing stale locks will resolve this issue.
What causes "E: Could not get lock /var/cache/apt/archives/lock - open (11: Resourc"?
Another apt process is currently running in the background (most common) Unattended security updates are in progress (on most Ubuntu/Debian systems) A previous apt operation was interrupted and left a stale lock file
Is the "E: Could not get lock /var/cache/apt/archives/lock - open (11: Resourc" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading