unattended-upgr) that run shortly after boot. Wait for it to finish, or check what holds the lock with ps aux | grep -E 'apt|dpkg'. Never delete the lock files.
Before you start
- This error is about APT and dpkg, the package tools of Ubuntu and Debian. AlmaLinux and Rocky use
dnf, which waits for its own lock by itself. - A lock is a marker a program sets so no second program changes the package database at the same time. Two installs at once can corrupt it.
- Commands use
sudo. As root, leave it out.
Cause 1: Automatic updates are running
Ubuntu and Debian install security updates in the background withunattended-upgrades. It runs on a daily timer that also catches up on missed runs at boot, so it is often busy soon after the server starts. The message then names unattended-upgr (the process name is cut to 15 characters) or apt.systemd.daily.
Check:
apt (which waits up to two minutes by default) or give apt-get a timeout in seconds:
Cause 2: You are running apt somewhere else
A second SSH session, a tmux or screen window, a control panel or a script may be installing something. Check which process holds the lock:Cause 3: An install was interrupted
If a lost SSH connection or a reboot stopped an install halfway, the lock is gone but dpkg reports:Cause 4: An apt process is stuck
Only if a process has used no CPU for a long time (for example 30 minutes or more) and isn’t waiting for input should you stop it. Check withps (Cause 1). If the process is waiting on the network, a broken mirror may be the reason: see apt and dnf repository errors.
Fix: stop it gently first, then repair:
sudo kill -9 1234 if the normal kill has no effect after a minute.
How to check it worked
Could not get lock line and end with Reading package lists... Done or a summary of upgradable packages.
Frequently asked questions
Why does this happen every time I log in to a new server?
On first boot the server checks for and installs security updates. Wait five to ten minutes after creating or rebuilding a server before you install software.Should I turn off unattended upgrades to avoid this?
No. They install security fixes. If you need control over timing, adjust them instead: see enable automatic security updates.What is the difference between lock and lock-frontend?
lock-frontend is held by the tool you run (apt, apt-get); lock is held by dpkg while it unpacks packages. /var/lib/apt/lists/lock is used by apt update. The fix is the same for all of them.
Related guides
VPS and dedicated server guides
Every guide in this section.
Update Linux packages
apt and dnf updates done right.
Automatic security updates
Configure unattended-upgrades.
apt and dnf repository errors
Release file, key and mirror errors.
Kill a process
Stop a stuck program safely.
Checked against the Debian dpkg FAQ on database locks and the official Ubuntu package management guide on 4 November 2026; the lock error, dpkg’s warning,
apt waiting for the lock and -o DPkg::Lock::Timeout were reproduced on a copy of the package database on Ubuntu 24.04 LTS (apt 2.8.3, dpkg 1.22.6).Need Extra Help?
If you encounter any issues, our support team is ready to assist:- Live Chat: Quick assistance via our website.
- Support Ticket: Open a Ticket
- Discord: Join our Community
- Email: support@freakhosting.com
Last Updated: November 2026