This error occurs when apt encounters corrupted package list files in /var/lib/apt/lists/. Corrupted files can result from network interruptions, gateway redirects to HTML pages, or hardware issues. The fix involves removing and regenerating package lists.
apt is unable to parse package metadata files because they lack the required "Package:" header field. This header is essential for apt to understand and catalog available packages. When apt downloads package lists from repositories, they should contain properly formatted metadata with package information. If a file is corrupted, truncated, or an HTML error page is downloaded instead of the package file, apt will fail to parse it and throw this error.
The most direct fix is to delete all cached package lists and regenerate them. Open a terminal and run:
sudo rm -rf /var/lib/apt/lists/*This removes all files in the apt cache directory that have become corrupted.
After removing the corrupted files, regenerate them by updating apt:
sudo apt-get updateThis downloads fresh package lists from all configured repositories.
Check that apt is working correctly by attempting to update or install a package:
sudo apt-get upgradeIf this command completes without errors, the issue is resolved.
If the issue persists, try a more conservative approach that uses apt's built-in recovery:
sudo apt-get clean
sudo apt-get update --fix-missingThis cleans the cache and updates while attempting to skip missing or incomplete files.
If you continue experiencing this error after the basic fixes, check your network connection and any captive portals. Some corporate networks or coffee shop WiFi redirect failed requests to login/help pages. These HTML pages end up in apt cache and cause parsing errors. You can also inspect /etc/apt/sources.list and /etc/apt/sources.list.d/ for invalid PPAs or third-party repositories that might be providing malformed metadata. Remove or fix any suspicious entries. In rare cases where /var/lib/dpkg/status is corrupted (as opposed to package lists), do not delete it directly—first backup the file from /var/backups/status, then restore it or consult system recovery guides.
E: Could not connect to proxy server
Could not connect to proxy server
E: Package 'package:i386' has no installation candidate
How to fix "Package package:i386 has no installation candidate" in apt
E: The value 'value' is invalid for APT::Default-Release
How to fix invalid APT::Default-Release value in APT
dpkg: error: unable to create new file 'path': Permission denied
How to fix dpkg permission denied errors in APT
subprocess installed post-removal script returned error exit status 1
How to fix "subprocess installed post-removal script returned error exit status 1" in APT