How to fix E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) in APT
This error occurs when the APT package manager cannot acquire an exclusive lock on the dpkg database, usually because another package management process is running. The lock file prevents simultaneous package operations that could corrupt the system.
Quick fix
Fixes EAGAIN (11)
ps aux | grep -E 'apt|dpkg'- Wait for background processes to complete
- Identify which process holds the lock
- Terminate the blocking process (if safe)
- Reconfigure broken packages
ps aux | grep -E 'apt|dpkg'E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
What this error means
When you run an apt command (apt install, apt update, apt upgrade, etc.), the system creates a lock file at /var/lib/dpkg/lock to prevent other processes from modifying the package database simultaneously. If another process holds the lock when you issue a command, apt cannot proceed and displays this "Resource temporarily unavailable" error. The error code 11 (EAGAIN) indicates the resource is temporarily busy. This commonly happens when Ubuntu's automatic updates run in the background at the same time you try to manually update packages, or when a previous apt/dpkg operation crashed without releasing the lock properly.
Typical symptoms
- apt, apt-get, or apt install commands fail with 'Could not get lock' message
- Software Center or package manager freezes or fails to open
- Unable to install or update any packages on Ubuntu or Debian
- Error appears shortly after system startup or during automatic updates
Common causes
- Another apt or dpkg process is running in the background (automatic updates, unattended-upgrades, Software Center)
- A previous package operation crashed without properly releasing the lock file
- Multiple package managers launched simultaneously (mixing apt, apt-get, snap, Software Center)
- System reboot or power loss interrupted an apt operation mid-way
How to fix "E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)"
The most common cause is Ubuntu's automatic background update process. Try waiting 5-15 minutes for it to finish.
Check if any apt processes are running:
ps aux | grep -E 'apt|dpkg'If you see processes like 'unattended-upgrades' or 'apt-get update', let them complete. You can also check the apt logs:
sudo tail -f /var/log/apt/history.logOnce you don't see any apt-related processes, your command should work.
If waiting doesn't work, check which process is holding the lock files:
sudo lsof /var/lib/dpkg/lock
sudo lsof /var/lib/apt/lists/lock
sudo lsof /var/cache/apt/archives/lockThis will show you the process ID (PID) holding each lock. The output shows the process name and ID. If you see a process that's stuck or no longer needed, you can proceed to the next step.
Only do this if you've confirmed a stalled process is holding the lock. Never kill a process that's actively installing critical system updates.
If the process is stuck or appears to be old (check with ps aux), terminate it:
sudo kill -9 <PID>Replace <PID> with the actual process ID from the previous step. After killing it, retry your apt command.
Warning: If the process is actively installing packages, killing it could leave your system in a broken state. Use this only as a last resort for stuck processes.
If apt operations were interrupted, dpkg's internal state may be corrupted. Repair it with:
sudo dpkg --configure -aThis command reconfigures any partially installed packages and fixes missing dependencies. Follow any prompts on screen. After this completes, try your apt command again.
If none of the above works, a reboot will clear all locks and running processes:
sudo rebootWait for the system to fully restart (2-3 minutes), then try your apt command. Upon boot, if there are pending package operations, apt will resume or complete them automatically.
Advanced notes
For systems with high load or those using unattended-upgrades, you can check the status of automatic updates with 'systemctl status apt-daily-upgrade.service'. On headless servers, disable the Software Center daemon entirely to prevent automatic background updates from locking dpkg.
On rare occasions, if lock files remain after a crash, you may need to manually remove them with 'sudo rm /var/lib/dpkg/lock*' and 'sudo rm /var/lib/apt/lists/lock', but only as an absolute last resort after confirming no processes are using dpkg. Removing lock files without cause can corrupt your package database.
Frequently asked questions
- What does "EAGAIN (11)" mean?
- ), the system creates a lock file at /var/lib/dpkg/lock to prevent other processes from modifying the package database simultaneously. If another process holds the lock when you issue a command, apt cannot proceed and displays this "Resource temporarily unavailable" error. The error code 11 (EAGAIN) indicates the resource is temporarily busy.
- How do I fix "EAGAIN (11)"?
- This error occurs when the APT package manager cannot acquire an exclusive lock on the dpkg database, usually because another package management process is running. The lock file prevents simultaneous package operations that could corrupt the system.
- What causes "EAGAIN (11)"?
- Another apt or dpkg process is running in the background (automatic updates, unattended-upgrades, Software Center) A previous package operation crashed without properly releasing the lock file Multiple package managers launched simultaneously (mixing apt, apt-get, snap, Software Center)
- Is the "EAGAIN (11)" error serious?
- Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.
Official resources & further reading
- ๐APT Official Documentation
- ๐NameHero: How to Fix dpkg lock Error(Official Docs)