This error occurs when another apt or package manager process is holding the lock on the package lists directory. The solution is to wait for the background process to complete, or identify and safely stop any blocking processes before running apt commands.
The apt package manager uses lock files to prevent multiple processes from modifying the package lists simultaneously. The lock file at /var/lib/apt/lists/lock is a safety mechanism that ensures package operations remain consistent. When you see "Resource temporarily unavailable" (errno 11), it means apt tried to acquire the lock but another process already has it. This commonly happens when Ubuntu's automated update system (unattended-upgrades) is running in the background, or when the Software Center or another package manager is actively downloading and updating the package cache.
The simplest and safest solution is to wait for any running package manager to complete. Close any GUI package managers (Software Center, Update Manager) and wait a few minutes:
# Check what process is holding the lock
sudo lsof /var/lib/apt/lists/lockIf you see "unattended-upgrade" in the output, your system is installing security updates. Let this complete before running apt. You can monitor its progress:
sudo systemctl status apt-daily-upgrade.serviceWait until the service shows "inactive" status.
Use lsof to see which process holds the lock file:
sudo lsof /var/lib/apt/lists/lockYou may also check other related lock files:
sudo lsof /var/lib/dpkg/lock-frontend
sudo lsof /var/lib/dpkg/lock
sudo lsof /var/cache/apt/archives/lockThe output will show the process name and PID. Common processes include:
- unattended-upgrade: Automatic security updates
- apt-get: Another apt operation
- apt: Direct apt command
- update-manager: Software update dialog
If a process is genuinely stuck (not just slow), you can forcefully terminate it. This is safer than removing lock files:
# Find the process ID from the lsof output above
sudo kill -9 <PID>Or use fuser to terminate all processes holding the lock:
sudo fuser -vik -TERM /var/lib/apt/lists/lockAfter killing the process, repair the package database:
sudo dpkg --configure -a
sudo apt updateIf no process is using the lock (lsof shows no output), the lock file may be stale. Remove it:
sudo rm /var/lib/apt/lists/lock
sudo rm /var/lib/dpkg/lock-frontend
sudo rm /var/lib/dpkg/lock
sudo rm /var/cache/apt/archives/lockThen update your package lists:
sudo apt updateVerify that apt directories have correct ownership and permissions:
sudo chown -R root:root /var/lib/apt/
sudo chmod 755 /var/lib/apt/lists
sudo chmod 755 /var/cache/apt/archives
sudo apt updateThese commands ensure the apt directories are owned by root with proper permissions.
If automated updates keep interfering with your work, you can disable them by editing the update configuration:
sudo nano /etc/apt/apt.conf.d/20auto-upgradesComment out (add // to the beginning) these lines:
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "7";
APT::Periodic::Unattended-Upgrade "1";Save with Ctrl+X, then Y, then Enter. This disables automatic background updates, allowing you to run apt manually when you choose.
The /var/lib/apt/lists/lock file is separate from the dpkg lock files. It specifically protects the package list cache (in /var/lib/apt/lists/) which contains metadata about all available packages. The unattended-upgrades daemon is a systemd service that runs scheduled checks and installs security patches automatically. It uses the apt package manager in the background, which is why you see lock conflicts. On systemd-based systems (Ubuntu 15.04+), you can check the status of all apt-related services with: sudo systemctl list-units | grep apt. For containerized or minimal systems without systemd, the automatic update mechanism may be different. In rare cases where the filesystem is read-only or quotas prevent lock file creation, you might see this error even when no process holds the lock—in those cases, check disk space with df -h and inode usage with df -i.
E: Could not connect to proxy server
Could not connect to proxy server
E: Package 'package:i386' has no installation candidate
How to fix "Package package:i386 has no installation candidate" in apt
E: The value 'value' is invalid for APT::Default-Release
How to fix invalid APT::Default-Release value in APT
dpkg: error: unable to create new file 'path': Permission denied
How to fix dpkg permission denied errors in APT
subprocess installed post-removal script returned error exit status 1
How to fix "subprocess installed post-removal script returned error exit status 1" in APT