Sub-process /usr/bin/dpkg returned an error code (1) 🐧 Linux

E: Sub-process /usr/bin/dpkg returned an error code (1)

A package’s install/configure script failed, so dpkg aborted. The real error is a few lines above this message.

Seen on: Linux

Meaning

dpkg runs maintainer scripts (postinst etc.). They fail when a service can’t start after install (port in use, bad config), a file conflicts with another package, or disk is full. The package stays half-configured until fixed.

Common causes

  • Package’s post-install script failed (service failed to start)
  • File conflict with another package (trying to overwrite)
  • Disk full during unpack
  • Broken previous install

⚡ Quick fix

  1. Read the lines above for the failing package and reason
  2. sudo dpkg --configure -a then sudo apt -f install
  3. Fix the underlying service/config error and retry

Detailed fix by platform

Ubuntu

  1. bash
    sudo dpkg --configure -a
    sudo apt-get -f install
    sudo journalctl -xe | tail -30   # if a service failed in postinst

How to diagnose

  1. Package — Which one failed?
  2. Reason — Message above (conflict, service, disk)
  3. Disk — df -h

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.