How to Fix apt Package Manager Errors on Ubuntu & Debian

APT errors can block updates and new installations entirely. This guide covers the most common APT errors and their direct fixes.

"Unable to Fetch Some Archives"

sudo apt update
sudo apt install PACKAGE_NAME --fix-missing

"E: Could Not Get Lock /var/lib/dpkg/lock-frontend"

Another process (often an automatic update running in the background) is currently using APT.

ps aux | grep apt

Wait for it to finish, or if genuinely stuck:

sudo rm /var/lib/dpkg/lock-frontend
sudo rm /var/lib/dpkg/lock
sudo dpkg --configure -a

Only remove lock files if you've confirmed no legitimate APT process is actually running.

"dpkg was interrupted, you must manually run 'sudo dpkg --configure -a'"

sudo dpkg --configure -a

"You Have Held Broken Packages"

sudo apt --fix-broken install
sudo apt full-upgrade

"GPG Error: The Following Signatures Couldn't Be Verified"

A repository's signing key is missing or expired.

sudo apt-key list

For a specific third-party repository, re-import its GPG key following that repository's official installation instructions (the exact command varies by provider).

"E: Unable to Locate Package"

sudo apt update

Run this first — the package list may simply be outdated. If the package still isn't found, confirm the exact package name and that the correct repository is enabled.

"Repository Does Not Have a Release File"

The repository entry in /etc/apt/sources.list or /etc/apt/sources.list.d/ references an incorrect or removed distribution codename — verify it matches your actual Ubuntu/Debian version:

cat /etc/os-release

Disk Space Errors During Installation

df -h

See How to Fix "No Space Left on Device" Errors if the disk is full.

Fixing a Broken System After a Bad Manual Edit

sudo apt update
sudo apt --fix-broken install
sudo dpkg --configure -a
sudo apt autoremove

Running these four commands in sequence resolves the majority of APT inconsistencies.

Removing a Problematic Third-Party Repository

sudo rm /etc/apt/sources.list.d/problematic-repo.list
sudo apt update

Common Errors

APT hangs indefinitely — check network connectivity to the repository mirrors; try a different mirror if one is consistently unreachable.

Errors persist after all fixes above — as a last resort, review /etc/apt/sources.list line by line for a malformed entry.

Best Practices

  • Always run apt update before troubleshooting further
  • Avoid interrupting an in-progress apt upgrade (e.g. via a forced reboot)
  • Be cautious adding third-party repositories — verify their trustworthiness first

Related Articles

  • How to Update and Upgrade Your Ubuntu or Debian VPS
  • How to Fix "No Space Left on Device" Errors
  • How to Enable Automatic Security Updates on Ubuntu & Debian
  • apt errors, dpkg errors, package manager, ubuntu troubleshooting
  • 0 Пользователи нашли это полезным
Помог ли вам данный ответ?

Связанные статьи

Website Down? A Step-by-Step Troubleshooting Checklist

When a website goes down, working through checks in the right order saves critical time. This...

VPS Unreachable/Can't Connect via SSH: Troubleshooting Guide

Losing SSH access to your VPS is stressful, but most causes are fixable without needing to...

How to Fix "No Space Left on Device" Errors

A full disk can silently break databases, log writing, package installations, and web...

How to Diagnose and Fix High CPU Usage on a VPS

Sustained high CPU usage can slow down your entire server and every application running on it....

How to Diagnose and Fix Out of Memory (OOM) Errors

When a Linux server runs out of available RAM, the kernel's OOM (Out of Memory) killer forcibly...