Fix apt-get unmet dependencies in Ubuntu 22.04
When apt-get refuses to install because it says 'unmet dependencies' or 'held broken packages', here's the fix that works 90% of the time.
You're running sudo apt-get install something and you get this wall of text that says something like unmet dependencies or held broken packages. Maybe you were trying to install a VPN client, or a Docker package, or something from a third-party PPA. I've seen this happen most often after you added a repository from Ubuntu's Software & Updates tool, then tried to upgrade. The package manager can't figure out which version of a library to keep.
What's actually happening
Your package list has two different sources trying to provide the same library (like libssl1.1 vs libssl3), and apt doesn't know which one to trust. It's not a hardware problem, it's not a virus. It's just a mismatch between what's installed and what's in the repositories you have enabled.
The real root cause: you probably have a PPAs or third-party repos enabled that are offering versions of packages that conflict with the official Ubuntu repos. Or you did a partial upgrade and left some packages half-installed.
The fix: step-by-step
I'm going to show you the method I've used on hundreds of Ubuntu machines. This works for 20.04, 22.04, and 24.04. Do these steps in order. Don't skip any.
- Open a terminal
PressCtrl+Alt+T. You'll see a black window with a blinking cursor. - Update your package list
Type:sudo apt update
After you press Enter, you'll see it download package lists from your repositories. This takes maybe 20 seconds. - Try to fix broken packages
Type:sudo apt --fix-broken install
This tells apt to look for packages that are partially installed or have missing dependencies. It will probably show you a list of packages to remove or install. TypeYand press Enter. After it finishes, you should see a message saying0 upgraded, 0 newly installed, 0 to removeor similar. - Clean the apt cache
Type:sudo apt clean
This clears the download cache. Won't break anything. - Upgrade everything
Type:sudo apt upgrade
This tries to upgrade all your packages to the latest versions their repositories provide. If it asks to install new packages, typeYand press Enter. - Force-configure any half-installed packages
Type:sudo dpkg --configure -a
This reconfigures any packages that got stuck during installation. You should see no errors after this command. If you see errors, write down which packages they mention. - Try your original install command again
Type the command you were trying to run, for example:sudo apt install openvpn
That's the standard fix. It works maybe 80% of the time.
If that doesn't work: the nuclear option
Sometimes a specific package is the troublemaker. Here's what I do then.
- Find the bad package
Run:sudo apt list --upgradable 2>/dev/null | grep -i held
This shows packages marked as "held back" — these often cause the dependency conflict. - Remove that package
If you see a package likelibssl1.1in the output, remove it with:sudo apt remove libssl1.1
TypeYwhen it asks to confirm. - Reinstall it from the correct repo
Type:sudo apt install libssl1.1
This time it should pull the right version from your main Ubuntu repositories.
I've done this with libc6, libssl, and libcurl conflicts. It works because you're removing the broken version first, then letting apt give you the good one.
Still failing? Check these things
- You have duplicate repositories
Open/etc/apt/sources.listwithsudo nano /etc/apt/sources.list. Look for lines that start withdeband have the same URL but different names (likefocalandjammymixed together). Comment out the wrong ones by putting a#at the beginning of the line. - You added a PPAs that's no longer maintained
Runls /etc/apt/sources.list.d/to see your PPAs. Remove any you don't need withsudo rm /etc/apt/sources.list.d/badrepo.list. Then runsudo apt updateagain. - Your system is too old for the repo
Ubuntu 22.04 repos work for 22.04 only. If you're on 20.04 and have a 22.04 repo, everything breaks. Check your Ubuntu version withlsb_release -a.
If none of this helped, you can try the last resort: backup your home folder, reinstall Ubuntu from scratch. I know that sounds extreme, but I've seen dependency conflicts that took hours to fix, and a fresh install takes 30 minutes. Sometimes it's the smart move.
Was this solution helpful?