English
Fix APT Lock
Symptoms
An install or update task on the server fails, and the Output of the event contains one of these lines:
text
E: Could not get lock /var/lib/dpkg/lock-frontend
E: Unable to acquire the dpkg frontend lock
E: Could not get lock /var/lib/apt/lists/lock
E: Unable to lock directory /var/lib/apt/lists/For the Unable to acquire the dpkg frontend lock error, the Solution section in the event details links to this page.
Cause
Ubuntu only lets one package program (apt, apt-get, dpkg) run at a time. The running program "locks" the package manager until it finishes. The error appears when:
- The server is installing security updates in the background (common right after a new server boots).
- A previous installation was interrupted (lost connection, server reboot…) and left the lock behind.
If the server is just updating itself, you usually only need to wait a few minutes and run the task again.
Fix it with the Fix APT Lock button
- Open the server and find the Utilities group on the overview page.
- Click Fix APT Lock.
- Read the description, then click Agree.
- Watch the Fix APT Lock event on the Events page. Once it succeeds, run the task that failed earlier again.
The utility will:
- Stop all running
aptandapt-getprocesses. - Remove the package manager lock files.
- Finish configuring any half-installed packages (
dpkg --configure -a). - Refresh the package list.
The button is disabled while the server is running another FlashPanel task; wait for that task to finish.
Warning
The utility immediately stops running apt processes, even ones that are installing or updating normally. Interrupting them can leave the package being installed broken. Only use it when you are sure no installation is running (for example, the error is still there after waiting 10–15 minutes).
Fix it manually
If the button does not solve the problem, connect via SSH as root and do the following:
See which program holds the lock:
bashsudo lsof /var/lib/dpkg/lock-frontend ps aux | grep -E 'apt|dpkg' | grep -v grepIf you see
unattended-upgradeor anaptcommand running, wait for it to finish.If the process is stuck (no change for a long time), stop it using the PID in the second column:
bashsudo kill <PID>Repair half-installed packages and refresh the package list:
bashsudo dpkg --configure -a sudo apt-get install -f sudo apt-get updateIf it still fails, reboot the server and try again. When contacting FlashPanel support, include the ID and Output of the failed event.
"dpkg was interrupted" error
The task fails with:
text
E: dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem.A previous package installation or upgrade stopped halfway (lost connection, server reboot, full disk…) and left some packages half-configured. The Solution section in the event details links to this section.
Make sure no installation or update is still running (step 1 of Fix it manually).
Click Fix APT Lock as described above; it also finishes configuring half-installed packages. Or run these commands as
root:bashsudo dpkg --configure -a sudo apt-get install -f sudo apt-get updateRun the task that failed again.
If these commands fail with No space left on device, free up disk space first, see Disk Full.