You run apt install or apt upgrade on your VPS, and instead of installing anything it prints a block of "Depends:" lines and finishes with E: Unable to correct problems, you have held broken packages. Don't worry, your server isn't broken. It means apt couldn't find a set of package versions that all work together, so it stopped before changing anything. Below is how we track down the real cause on customer VPSes and fix it without pulling the system apart.
What the Error Actually Looks Like
Here's a typical example from an Ubuntu VPS:
The following packages have unmet dependencies:
php8.3-mysql : Depends: php8.3-common (= 8.3.6-0ubuntu0.24.04.3) but 8.3.14-1+ubuntu24.04.1+deb.sury.org+1 is to be installed
E: Unable to correct problems, you have held broken packages.
The last line is generic. The useful part is the "Depends:" line above it, which tells you which package wants which version and what apt is trying to install instead. Always read that line first.
Why It Happens
Despite the wording, an actual held package is only one of several causes. In practice we see these:
- Mixed repositories. A third-party repo or PPA (PHP, MariaDB, Node.js, Docker) ships newer versions of packages that the official repo also provides, so the versions no longer line up.
- A package really is on hold. Someone ran
apt-mark holdon a kernel, MySQL or PHP package months ago and forgot about it. - A half-finished install or upgrade. An SSH drop or a full disk interrupted dpkg, so some packages are unpacked but not configured.
- Repos for the wrong release. A
jammyrepo line left behind on anoble(24.04) server, or a Debian repo added to Ubuntu. - Stale package lists. The local index is out of date, or a mirror is partway through a sync.
Step 1: Refresh Package Lists and Finish Interrupted Work
Start with the basics. Plenty of "held broken packages" errors go away at this step:
sudo apt update
sudo dpkg --configure -a
sudo apt --fix-broken install
dpkg --configure -a finishes configuring anything that was left unpacked. apt --fix-broken install (the same as apt-get install -f) tries to fill in missing dependencies. Check free space too, because a full disk is a common reason dpkg stopped in the first place:
df -h / /boot
If / or /boot is close to 100%, clear space before you go further, or the next install will fail the same way.
Step 2: Look for Packages That Are Actually Held
apt-mark showhold
If this prints something related to the package you're installing (for example mysql-server-8.0 or php8.3-common), that's very likely the cause. Check why it was held before you release it. Sometimes a hold is deliberate, for instance to keep a database on a version your app has been tested with. To release it:
sudo apt-mark unhold php8.3-common
sudo apt update
sudo apt install php8.3-mysql
You can also run dpkg --audit to list packages that are only partly installed or have broken configuration.
Step 3: Find Out Which Repository Is Fighting
This is where most cases get solved. Run apt-cache policy on the package named in the "Depends:" line:
apt-cache policy php8.3-common
The output lists every version available and which repo each one comes from:
php8.3-common:
Installed: 8.3.6-0ubuntu0.24.04.3
Candidate: 8.3.14-1+ubuntu24.04.1+deb.sury.org+1
Version table:
8.3.14-1+ubuntu24.04.1+deb.sury.org+1 500
500 https://ppa.launchpadcontent.net/ondrej/php/ubuntu noble/main amd64 Packages
*** 8.3.6-0ubuntu0.24.04.3 500
500 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Packages
Here the installed version came from Ubuntu while the candidate comes from a PPA, and the package you asked for was built for the other one. Now list the repos the server has enabled:
ls /etc/apt/sources.list.d/
grep -rh "^deb\|^URIs\|^Suites" /etc/apt/sources.list /etc/apt/sources.list.d/
Ubuntu 24.04 uses the newer deb822 format (.sources files with URIs: and Suites: lines), so the grep covers both formats. Look for:
- A codename that doesn't match your release. Check yours with
lsb_release -csor. /etc/os-release; echo $VERSION_CODENAME. - Two repos supplying the same software, such as Ubuntu's PHP and the ondrej PPA, or Ubuntu's MariaDB and the MariaDB.org repo.
- Repos you no longer need from old experiments.
Step 4: Pick One Fix
Pick the fix that matches what you found. Don't run all of them.
| What you found | Fix |
|---|---|
| Third-party repo is the one you want | Upgrade the related packages together so they all come from that repo: sudo apt install php8.3-common php8.3-mysql php8.3-cli |
| Third-party repo isn't needed | Remove it and downgrade back to the official versions (see below) |
| Repo for the wrong release | Correct the codename in the file, or delete the file, then run apt update |
| One package needs a specific version | Install that exact version: sudo apt install php8.3-mysql=8.3.6-0ubuntu0.24.04.3 |
| apt's solver just gives up | Let aptitude suggest a fix (see below) |
Removing a PPA and going back to official packages
The cleanest way is ppa-purge, which removes the PPA and downgrades its packages back to the Ubuntu versions:
sudo apt install ppa-purge
sudo ppa-purge ppa:ondrej/php
If it's an ordinary third-party repo rather than a PPA, delete its file in /etc/apt/sources.list.d/, run sudo apt update, and then install the official version explicitly with the package=version form from apt-cache policy.
Using aptitude to find a way through
apt's resolver is fairly conservative. aptitude will search for alternatives and show you what it plans to do before it does anything:
sudo apt install aptitude
sudo aptitude install php8.3-mysql
Its first suggestion is often "keep the current version", which does nothing. Press n to see the next option. Read every suggestion carefully. If one wants to remove packages like mysql-server, nginx or openssh-server, reject it. Accepting that kind of plan on a production server is how a five-minute fix turns into an outage.
Step 5: Use Simulation Before You Commit
Once you think it's fixed, do a dry run before the real install:
sudo apt install -s php8.3-mysql
The -s flag shows exactly what would be installed, upgraded or removed, without changing anything. If the list looks sensible, run it again without -s.
A Quick Note on Debian
Everything above works the same way on Debian, except PPAs. Watch out for backports on Debian: packages from backports only install when you ask for them explicitly with apt install -t bookworm-backports package, so mixing them with normal installs can produce this same error.
How to Prevent It
- Keep third-party repos to a minimum. Each one you add is another source that can conflict. Write down why you added each one.
- Use pinning when a repo should only supply some packages. A file such as
/etc/apt/preferences.d/mariadbcan make that repo win only for MariaDB packages. - Don't leave holds in place forever. Check
apt-mark showholdevery few months. - Run upgrades inside
screenortmuxso an SSH drop can't leave dpkg half-finished. - Take a snapshot before major upgrades. On a SkyServer VPS a snapshot takes a minute and gives you a clean way back.
- Clean up old repos after a release upgrade.
do-release-upgradedisables third-party repos. Re-enable only the ones that publish builds for your new release.
Frequently Asked Questions
Is it safe to run apt --fix-broken install on a live server?
Usually yes, but read what it plans to do before you type Y. If the list includes removing important packages (web server, database, SSH), stop and investigate instead.
I never held any packages. Why does the error say "held"?
The wording is misleading. apt uses "held" loosely to mean packages it decided to keep at their current version because it couldn't find a working upgrade path. Mixed repositories cause this far more often than real holds.
Will removing a PPA uninstall my software?
Deleting the repo file doesn't remove anything that's already installed. It only stops future updates from that source. ppa-purge goes further and downgrades those packages to the official versions, which can mean a lower PHP or database version, so check that your apps support it.
Should I just use dpkg --force to push the package in?
No. Forcing dependencies with dpkg leaves the package database inconsistent, and every later apt command will complain. Fix the repository conflict instead.
What if none of this works?
Copy the full output of apt install -s <package>, apt-cache policy <package> and apt-mark showhold, then open a ticket with SkyServer support. With those three outputs we can usually find the conflicting repo straight away.
