How to Fix Broken Packages and Unmet Dependencies on Ubuntu

When a package installation or upgrade fails on Ubuntu, the next apt command may report unmet dependencies or ask you to finish an interrupted installation. This can happen after a system shutdown, a failed configuration script, or an installation from a third-party repository.
This guide explains how to fix broken packages on Ubuntu with apt and dpkg, and how to find held packages and repository conflicts when the standard repair commands do not solve the problem.
You need a user with sudo privileges to run the repair commands. If another package manager or automatic update is running, let it finish before you begin.
Quick Reference
For a printable quick reference, see the apt cheatsheet .
| Task | Command |
|---|---|
| Finish interrupted installations | sudo dpkg --configure -a |
| Preview dependency repairs | sudo apt --simulate --fix-broken install |
| Repair broken dependencies | sudo apt --fix-broken install |
| Refresh package lists | sudo apt update |
| Clear the package cache | sudo apt clean |
| List packages on hold | apt-mark showhold |
| Check for incomplete package installations | dpkg --audit |
| Check installed package dependencies | sudo apt-get check |
| Show a package’s versions and sources | apt policy package_name |
| Reinstall a package | sudo apt install --reinstall package_name |
What the Errors Mean
The error message helps you decide where to start. An unmet dependency means that apt cannot find a combination of package versions that satisfies the installation request. On Ubuntu 24.04 and earlier, the message looks like this:
The following packages have unmet dependencies:
myapp : Depends: libfoo1 (>= 2.4) but 2.2-1ubuntu1 is to be installed
E: Unable to correct problems, you have held broken packages.Ubuntu 26.04 ships apt 3, which uses a new dependency solver and reports the same problem differently:
Unsatisfied dependencies:
myapp : Depends: libfoo1 (>= 2.4) but 2.2-1ubuntu1 is to be installed
Error: Unable to satisfy dependencies. Reached two conflicting assignments:
1. myapp:amd64=1.0 is selected for install
2. myapp:amd64 Depends libfoo1 (>= 2.4)
but none of the choices are installable:
[no choices]In both examples, myapp needs libfoo1 version 2.4 or later, but apt has selected version 2.2. The package names and versions are illustrative. The phrase “held broken packages” does not prove that you have placed a package on hold. Missing repositories, incompatible package versions, and package pinning can also prevent apt from finding a solution.
If an earlier installation left unmet dependencies behind, apt refuses to install anything else until you repair them:
You might want to run 'apt --fix-broken install' to correct these.
Unsatisfied dependencies:
myapp : Depends: libfoo1 but it is not going to be installed
Error: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).On Ubuntu 24.04 and earlier, the list starts with “The following packages have unmet dependencies:” and the error line begins with E:.
An interrupted package operation can produce a different message:
E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.Here, apt needs dpkg to finish the pending package configuration before it can continue. This does not tell you whether the configuration will succeed; missing dependencies or a failing package script may still need attention. On Ubuntu 26.04, apt starts this message with Error: instead of E:.
Complete Interrupted Installations
If apt reports an interrupted dpkg operation, start with the command it suggests:
sudo dpkg --configure -aThe --configure option finishes configuring unpacked packages, and -a applies it to all pending packages. On a system with no pending work, the command normally prints nothing. After an interrupted upgrade, it can take a while to finish.
To check for incomplete installations and package database problems, run:
dpkg --auditThe output identifies affected packages and may suggest the next action. If configuration fails because a dependency is missing, continue with the dependency repair below. If a package script fails, read the error above the final dpkg message before trying the command again.
Refresh Package Lists
Before asking apt to install missing dependencies, refresh the package lists:
sudo apt updateThis downloads package information from your configured repositories. Check the output for errors. A repository that cannot be reached or does not support your Ubuntu release may leave apt without the dependency versions it needs. Fix those errors before continuing.
Repair Broken Dependencies
The --fix-broken option (-f for short) asks apt to repair dependencies of packages already installed or unpacked on the system. First, preview the proposed changes:
sudo apt --simulate --fix-broken installThe --simulate option shows the proposed package operations without installing or removing anything. Review any removals, especially desktop, kernel, networking, or other packages you depend on. If the plan looks appropriate, run the repair:
sudo apt --fix-broken installYou do not need to name a package. Apt works out which dependencies to install and which conflicting packages may need to be removed. For example, part of the output may look like this:
Correcting dependencies... Done
Installing dependencies:
libfoo1
...
Do you want to continue? [Y/n]Here, apt proposes installing the missing libfoo1 package. Review the actual plan again before confirming it, since the system state may have changed since the simulation. Leave off -y so you can respond to the confirmation prompt.
After the repair, retry the command that failed. If it succeeds, you do not need to continue through the remaining fixes. If apt reports no changes but the original installation still fails, check the holds and available package versions below. A repair cannot supply a dependency that is absent from your repositories or make incompatible packages work together.
If a downloaded .deb archive is damaged, you can clear the package cache and retry the download:
sudo apt cleanThis removes cached package archives, including partial downloads, without removing installed packages. It does not resolve version conflicts or repair repository configuration. For everyday installation and upgrade commands, see our apt guide .
Check for Held Packages
A package on hold is protected from automatic installation, upgrade, or removal. If another package needs a newer version of a held library, apt may be unable to complete the installation. List the holds with:
apt-mark showholdIf the output names a package involved in your error, find out why it was held before changing it. If the hold is no longer needed, remove it and retry the failed command. Replace package_name with the affected package:
sudo apt-mark unhold package_nameNo output from showhold means there are no explicit holds. You should still check available versions and repository priorities, since pinning and missing sources can cause similar errors.
Find Version Conflicts from PPAs
PPAs and other third-party repositories can replace Ubuntu packages with incompatible versions. A package that depends on an exact library version may then become uninstallable. Use apt policy to check the installed version, the candidate apt would select, and the versions in your current package lists:
apt policy libfoo1For example, the following illustrative output shows a PPA version alongside an Ubuntu 24.04 version:
libfoo1:
Installed: 2.5-1~ppa1
Candidate: 2.5-1~ppa1
Version table:
*** 2.5-1~ppa1 500
500 https://ppa.launchpadcontent.net/example/ppa/ubuntu noble/main amd64 Packages
100 /var/lib/dpkg/status
2.2-1ubuntu1 500
500 http://archive.ubuntu.com/ubuntu noble/main amd64 PackagesThe *** marker identifies the installed version. In this example, that version is also available from the PPA URL shown beneath it. Check the repository URLs and priorities rather than relying on a ~ppa suffix, since version names alone do not establish a package’s origin.
If the candidate is not the version you expect, also check for package pins in /etc/apt/preferences and /etc/apt/preferences.d/. Do not replace your Ubuntu release codename with another release just to obtain a newer dependency.
If you have confirmed that a PPA is causing the conflict, ppa-purge can disable it and attempt to return affected packages to Ubuntu versions. Review the proposed downgrades and removals before accepting them. Packages without an Ubuntu replacement may be removed.
Install the tool, then run it for the affected PPA. Replace example/ppa with its actual owner and archive name:
sudo apt install ppa-purge
sudo ppa-purge ppa:example/ppaThe PPA must still be enabled and reachable for ppa-purge to read its package lists. If broken dependencies prevent you from installing the tool, inspect the package-specific options in the next section.
Removing the PPA with add-apt-repository --remove only stops future downloads from that source; it leaves installed PPA versions in place. For more on managing repositories, see How to Add Apt Repository in Ubuntu
.
Reinstall or Remove the Problem Package
If a package’s installed files are missing or damaged, try reinstalling it:
sudo apt install --reinstall package_nameReinstallation replaces packaged files and runs the package’s installation scripts again. It does not normally reset modified configuration files, and apt may also change dependencies, so review the proposed changes. If the same script fails again, you need to fix the cause reported in its output.
If you do not need the affected package, preview its removal:
sudo apt --simulate remove package_nameCheck which other packages would be removed. If the plan is acceptable, run:
sudo apt remove package_nameAfter removal, run sudo apt --fix-broken install again if dependency problems remain.
--force-remove-reinstreq only as a last resort when dpkg explicitly marks the package as requiring reinstallation and reinstalling it has failed. The option bypasses that removal restriction and can leave files behind that dpkg no longer tracks. It does not bypass dependency checks or fix failing maintainer scripts. Do not use it to remove essential system packages.For a package in that specific state, the command is:
sudo dpkg --remove --force-remove-reinstreq package_nameFollow it with sudo apt --fix-broken install and review the proposed repair. Install the package again if you still need it. The lower-level options used here are covered in the dpkg command guide
.
Check the Package State After Repair
Once the repair finishes, check for incomplete package installations and broken dependencies:
dpkg --audit
sudo apt-get checkThe audit should print nothing, and apt-get check should finish without dependency errors. These checks cover package state and dependencies; they do not verify that every application works correctly. Retry the installation or upgrade that originally failed.
Troubleshooting
The following packages have been kept back
A kept-back package is not necessarily broken. Check apt policy package_name for a phasing percentage. If Ubuntu is still phasing the update, wait for it to become available to your system. Otherwise, check explicit holds and dependency conflicts. apt upgrade can install new dependencies but will not remove installed packages; full-upgrade can remove them. Review the differences in our apt update and upgrade guide
before choosing an upgrade command.
Could not get lock /var/lib/dpkg/lock-frontend
Another process is using the package system, often unattended-upgrades or Software Updater. Wait for it to finish and retry. The error usually includes the process ID holding the lock. Do not delete lock files; follow our APT and dpkg lock error guide
to identify the owner and handle a stuck process.
apt –fix-broken install wants to remove many packages
Answer n and inspect the dependency named in the error with apt policy package_name. Incompatible repository versions, missing sources, and package pins can all lead apt to propose removals. Resolve the underlying conflict before accepting a plan that removes software you need.
The same package fails during its configuration step every time
If the error names a post-installation script, run sudo dpkg --configure package_name and read the messages above the final error. They may identify a service that failed to start, invalid configuration, or a missing file. Correct that cause before retrying; clearing the apt cache will not fix a failing script.
Conclusion
Use packages built for your Ubuntu release, and check which system libraries a PPA would replace before enabling it. If a repair removed software, list your installed packages and reinstall the applications you still need.
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 1000+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page