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

**Code:** `dpkg lock` · **Category:** Linux · **Seen on:** Linux

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

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/linux/could-not-get-lock-dpkg)
