Fix 'dpkg was interrupted' Error: Run dpkg --configure -a

When dpkg is interrupted during package installation or upgrade, it locks the package manager. Running 'sudo dpkg --configure -a' completes pending configurations and resolves the issue.

Symptoms

When running apt-get install, apt-get upgrade, or any dpkg command, you encounter an error message similar to:

E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.

Other symptoms include:

  • Package manager (APT) refuses to install or remove packages.
  • System update fails with the same dpkg interruption message.
  • Lock file errors such as Could not get lock /var/lib/dpkg/lock-frontend.
  • Packages left in an inconsistent state (half-installed or half-configured).

Root Causes

The error occurs when a dpkg operation (installation, removal, or upgrade) is unexpectedly interrupted. Common causes include:

  • Power failure or system crash during package installation.
  • User pressing Ctrl+C while dpkg is running.
  • Network timeout during package download that leaves dpkg in an incomplete state.
  • Running multiple package manager processes simultaneously (e.g., two terminals running apt at once).
  • Killing the package manager process with kill or killall.

Step-by-Step Fix

1. Run dpkg --configure -a

Open a terminal and execute:

sudo dpkg --configure -a

This command reconfigures all unpacked but not yet configured packages. It will attempt to complete any pending configurations. If dpkg prompts for input (e.g., timezone or service restart), provide the appropriate answers.

2. Check for Remaining Issues

After the command finishes, run:

sudo apt-get check

This verifies the package database consistency. If no errors appear, the fix is complete.

3. Update Package Lists

Finally, update the package index:

sudo apt-get update

Then perform a full upgrade to ensure all packages are up-to-date:

sudo apt-get upgrade

Alternative Fixes

If dpkg --configure -a Fails

If the command itself fails or hangs, try the following:

  • Remove lock files (if dpkg claims a lock exists):
    sudo rm /var/lib/dpkg/lock-frontend
    sudo rm /var/lib/apt/lists/lock
    sudo rm /var/cache/apt/archives/lock
  • Force reconfigure with verbose output:
    sudo dpkg --configure -a --force-depends
  • Fix broken packages:
    sudo apt-get install -f

Reset dpkg Database

In extreme cases, you may need to reset the dpkg database (advanced users only):

sudo mv /var/lib/dpkg/info /var/lib/dpkg/info_old
sudo mkdir /var/lib/dpkg/info
sudo apt-get update
sudo apt-get install -f

Prevention

  • Never interrupt dpkg or apt-get processes with Ctrl+C unless absolutely necessary.
  • Avoid running multiple package manager instances simultaneously.
  • Ensure stable power (use a UPS) and network connection during system updates.
  • Always run sudo apt-get update before major upgrades to reduce the chance of network timeouts.
  • If you must cancel an operation, wait for dpkg to finish its current package before using Ctrl+C.

Following these steps will resolve the 'dpkg was interrupted' error and restore normal package management functionality on your Linux system.

Related Errors in Linux & Unix
502 Bad Gateway Nginx 502 Bad Gateway: Quick Fix for PHP-FPM Issues EMFILE Linux EMFILE: 'Too many open files' — fix file descriptor limits X11 server crash: fix the black screen right now Fix SSH Permission Denied with Public Key Authentication

Was this solution helpful?

EP
Erropedia Team
Tech Support Editors
The Erropedia editorial team researches and documents real-world tech errors from across Windows, Linux, macOS, networking, databases, cloud platforms, and more. Every solution is reviewed for accuracy and updated as software and systems evolve.