dpkg lock 🐧 Linux

E: Could not get lock /var/lib/dpkg/lock-frontend — is another process using it?

apt can’t run because another package operation (often automatic updates) holds the dpkg lock.

Seen on: Linux

Meaning

Only one apt/dpkg process may run at a time. On fresh servers, unattended-upgrades frequently runs right after boot. Deleting the lock files while a process is running can corrupt the package database.

Common causes

  • unattended-upgrades / apt-daily running
  • Another terminal or script running apt
  • A previous apt run crashed and left dpkg half-configured

⚡ Quick fix

  1. Wait a few minutes and retry
  2. See what holds it: sudo lsof /var/lib/dpkg/lock-frontend
  3. If nothing runs: sudo dpkg --configure -a
  4. Never delete lock files while apt/dpkg is running

Detailed fix by platform

Linux

  1. Find the holder and recover:
    bash
    ps aux | grep -E 'apt|dpkg|unattended' | grep -v grep
    sudo lsof /var/lib/dpkg/lock-frontend
    # only when no apt/dpkg process is running:
    sudo dpkg --configure -a
    sudo apt -f install

How to diagnose

  1. Holder — Which process owns the lock?
  2. State — Interrupted dpkg run?

🧠 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.