How to fix unattended-upgrades: Error during package installation in APT

APTINTERMEDIATEHIGHUpdated Dec 29, 2025· 242 views

The unattended-upgrades service fails during automatic package installation due to lock files, broken dependencies, or configuration issues. This prevents automatic security updates from completing.

Quick fix

Fixes unattended-upgrades: Error during package installation

sudo cat /var/log/unattended-upgrades/unattended-upgrades.log | tail -50
  1. Check the unattended-upgrades log for specific errors
  2. Fix broken dpkg state
  3. Fix broken package dependencies
  4. Verify unattended-upgrades is properly installed
apt — error
sudo cat /var/log/unattended-upgrades/unattended-upgrades.log | tail -50
unattended-upgrades: Error during package installation

What this error means

This error occurs when the unattended-upgrades daemon encounters an issue while trying to automatically install or upgrade packages. The daemon runs in the background to keep your system secure by installing security patches without requiring manual intervention. When it encounters errors—such as locked dpkg files, broken package dependencies, configuration conflicts, or missing dependencies—it stops the installation process and logs the error. This means critical security updates may not be applied to your system. The error typically happens when: another apt process is running and locks the dpkg database, a previous upgrade was interrupted leaving the system in an inconsistent state, the package requires user interaction (like choosing between configuration file versions), or system dependencies are broken.

Typical symptoms

  • Automatic updates stop running and no packages are installed
  • Manual apt commands work fine but unattended-upgrades fails silently
  • Logs in /var/log/unattended-upgrades/unattended-upgrades.log show installation errors
  • Security patches are not applied automatically to the system
  • Running 'sudo systemctl status unattended-upgrades' shows errors or failures

Common causes

  1. Another apt or dpkg process is running, locking the package database
  2. A previous apt upgrade was interrupted, leaving dpkg in an inconsistent state
  3. Broken or held packages with unmet dependencies
  4. Configuration files need user interaction (package manager asking which version to keep)
  5. Missing PATH environment variables (/sbin, /usr/sbin) in the upgrade environment
  6. Packages requiring unavailable dependencies from unapproved package sources
  7. Mail configuration issues if notifications are enabled

How to fix "unattended-upgrades: Error during package installation"

1Check the unattended-upgrades log for specific errors

View the error log to understand what went wrong:

bash
sudo cat /var/log/unattended-upgrades/unattended-upgrades.log | tail -50

Also check the apt history:

bash
sudo cat /var/log/apt/history.log | tail -30

Look for specific error messages that indicate the root cause (lock files, broken dependencies, post-installation script failures, etc.).

2Fix broken dpkg state

If dpkg is in an inconsistent state from an interrupted upgrade:

bash
sudo dpkg --configure -a

If configuration conflicts exist, force the old config to be kept:

bash
sudo dpkg --force-confold --configure -a

Then update package lists:

bash
sudo apt update
3Fix broken package dependencies

Repair any broken or held packages:

bash
sudo apt --fix-broken install
sudo apt --fix-missing install

If packages are held (marked to not be upgraded), list and review them:

bash
sudo apt-mark showhold

To unhold a specific package:

bash
sudo apt-mark unhold package-name
4Verify unattended-upgrades is properly installed

Reinstall the package to ensure it's in a clean state:

bash
sudo apt install unattended-upgrades -y

If that fails, force-remove and reinstall:

bash
sudo apt remove --purge unattended-upgrades
sudo apt autoremove
sudo apt update
sudo apt install unattended-upgrades
5Test with dry-run before enabling automatic upgrades

Before relying on automatic upgrades, test the configuration:

bash
sudo unattended-upgrade --dry-run --debug

This shows exactly what would be upgraded without making changes. Review the output for any errors or warnings.

6Enable and verify unattended-upgrades is running

Ensure the service is enabled and running:

bash
sudo systemctl enable unattended-upgrades
sudo systemctl restart unattended-upgrades
sudo systemctl status unattended-upgrades

Check that it runs on the configured schedule. The service typically runs once per day (check /etc/apt/apt.conf.d/20auto-upgrades).

Advanced notes

Configuration Management: Edit /etc/apt/apt.conf.d/50unattended-upgrades to control which package origins are allowed for automatic upgrades. Packages from unapproved sources will be held back even if updates are available.

Debug Mode: Add Unattended-Upgrade::Debug "true"; to /etc/apt/apt.conf.d/50unattended-upgrades to enable verbose logging. This helps identify the exact point where installation fails.

Automatic Reboot: If you enable automatic reboots, ensure the system is configured to notify users. Check the Unattended-Upgrade::Automatic-Reboot* settings in the configuration file.

Mail Notifications: If mail notifications are enabled, verify mailutils or bsd-mailx is installed. Failing mail delivery can cause the service to report errors even if upgrades succeeded.

Lock File Issues: If you see "/var/lib/dpkg/lock" errors, another process may be running. Wait for background updates to complete, or force-remove stale lock files only if you're certain no other apt processes are active: sudo rm -f /var/lib/dpkg/lock-frontend /var/lib/apt/lists/lock.

SELinux/AppArmor: On systems with mandatory access control, ensure unattended-upgrades has the necessary permissions to write logs and manage packages.

Frequently asked questions

What does "unattended-upgrades: Error during package installation" mean?
This error occurs when the unattended-upgrades daemon encounters an issue while trying to automatically install or upgrade packages. The daemon runs in the background to keep your system secure by installing security patches without requiring manual intervention. When it encounters errors—such as locked dpkg files, broken package dependencies, configuration conflicts, or missing dependencies—it stops the installation process and logs the error.
How do I fix "unattended-upgrades: Error during package installation"?
The unattended-upgrades service fails during automatic package installation due to lock files, broken dependencies, or configuration issues. This prevents automatic security updates from completing.
What causes "unattended-upgrades: Error during package installation"?
Another apt or dpkg process is running, locking the package database A previous apt upgrade was interrupted, leaving dpkg in an inconsistent state Broken or held packages with unmet dependencies
Is the "unattended-upgrades: Error during package installation" 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