How to fix E: Encountered a section with no Package: header in APT
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.
Quick fix
Fixes E: Encountered a section with no Package: header
sudo rm -rf /var/lib/apt/lists/*- Remove corrupted package lists
- Regenerate package lists
- Verify the fix
- Alternative: Clean and update with fix-missing
sudo rm -rf /var/lib/apt/lists/*E: Encountered a section with no Package: header
What this error means
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.
Typical symptoms
- apt update command fails with the error message
- Unable to install or upgrade packages
- Synaptic or other package managers fail to refresh
- System cannot retrieve available packages from repositories
Common causes
- Network interruption during package list download
- Gateway or router redirecting to an HTML error page instead of package files
- Corrupted or incomplete files in /var/lib/apt/lists/
- Repository providing malformed package metadata
- Disk corruption or faulty hardware
How to fix "E: Encountered a section with no Package: header"
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.
Advanced notes
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.
Frequently asked questions
- What does "E: Encountered a section with no Package: header" mean?
- 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.
- How do I fix "E: Encountered a section with no Package: header"?
- 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.
- What causes "E: Encountered a section with no Package: header"?
- Network interruption during package list download Gateway or router redirecting to an HTML error page instead of package files Corrupted or incomplete files in /var/lib/apt/lists/
- Is the "E: Encountered a section with no Package: header" error serious?
- It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- 📚APT Official Documentation
- 📖Debian Wiki: SourcesList(Official Docs)