This error occurs when the APT package manager runs out of disk space while downloading packages. Clear the cache and reclaim storage from unused dependencies and applications.
APT (Advanced Package Tool) caches downloaded package files in /var/cache/apt/archives/ to avoid re-downloading them during future installations. When this directory or the root partition runs out of space, APT cannot proceed with updates or installations. This typically happens on systems with limited storage, such as Raspberry Pi devices, containerized environments, or machines with multiple large applications installed.
Run these commands to remove cached package files:
sudo apt-get clean
sudo apt-get autoclean- apt-get clean: Removes all cached .deb files from /var/cache/apt/archives/
- apt-get autoclean: Removes only obsolete cached files that can no longer be downloaded from repositories
This typically frees up several hundred MB to a few GB of space.
Run this command to remove packages that were automatically installed as dependencies but are no longer needed:
sudo apt-get autoremoveYou may also want to remove unnecessary packages you've manually installed:
sudo apt-get remove PACKAGENAMEReplace PACKAGENAME with any unnecessary packages. You can list installed packages with apt list --installed.
Verify how much space you've freed and identify what else is consuming disk space:
df -h /
sudo du -h --max-depth=1 /var | sort -h | tail -n 10The first command shows overall root partition usage. The second shows what's consuming the most space in /var. Common culprits include:
- /var/log: System logs (check with ls -lahS /var/log)
- /var/lib: Databases, Docker images, package managers
- /var/cache: Other cached application data
You can safely delete old log files if needed:
sudo rm /var/log/auth.log.1 /var/log/syslog.1If after cleaning the cache you still lack space, identify and remove large applications you don't need:
sudo apt-get remove APPLICATIONNAME
sudo apt-get autoremoveCommon space-consuming applications:
- Docker/Podman: Often stores gigabytes of images
- LibreOffice: Large office suite
- Unnecessary language packs or fonts
Check what's actually using space:
du -h --max-depth=1 /var/lib | sort -h | tail -n 5Once you've freed sufficient space, retry your original command:
sudo apt-get install PACKAGENAME
# or
sudo apt-get upgradeYou should now have enough space to download and cache the necessary package files.
On Raspberry Pi devices with limited storage, you may need to expand the root filesystem using sudo raspi-config and selecting the expand root filesystem option. For systems using LVM (Logical Volume Manager), you can dynamically allocate more space to /var without reinstalling: run sudo pvresize /dev/sdXN followed by sudo lvextend -l +100%FREE /dev/vg0/root and sudo resize2fs /dev/vg0/root. On systems running in Docker or VirtualBox, consider increasing the virtual disk size in the VM settings before expanding partitions. The journal log file (journalctl) can be trimmed with sudo journalctl --vacuum-size=64M to reclaim additional space without affecting active services. For production systems, consider implementing logrotate to automatically compress and remove old logs: check /etc/logrotate.d/ for existing policies.
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