This error occurs when trying to remove a foreign architecture (like i386) from dpkg while packages from that architecture are still installed. You must uninstall all packages from the target architecture before removing it.
When you run `dpkg --remove-architecture i386`, dpkg checks if any packages from that architecture are still installed in the system. If packages exist, dpkg refuses to remove the architecture to prevent breaking the system. This is a safety mechanism because some applications may depend on 32-bit libraries even on 64-bit systems. The error specifically means the dpkg database still contains references to packages or dependencies from the i386 architecture. Until all those packages are purged, the architecture record cannot be removed.
First, check which i386 packages you have:
dpkg -l | grep ':i386'This shows a list of all packages with the :i386 suffix. Note which ones are installed (marked with 'ii' in the first column).
Use apt-get to cleanly purge all i386 packages from the system:
sudo apt-get purge '.*:i386'The purge command removes both the package and its configuration files, ensuring a clean removal. The wildcard pattern matches any package ending in :i386.
If apt asks for confirmation, type 'y' and press Enter. This step removes all multiarch packages at once.
Confirm that no i386 packages remain:
dpkg -l | grep ':i386'This command should now return no output, meaning all i386 packages have been successfully removed.
Now that all i386 packages are gone, you can safely remove the architecture:
sudo dpkg --remove-architecture i386This command should complete without error.
Confirm that i386 is no longer registered in dpkg:
dpkg --print-foreign-architecturesThis should return nothing or show only other architectures if you have multiple. The i386 architecture should no longer appear.
Optionally, verify your primary architecture is unchanged:
dpkg --print-architectureThis should still show your primary architecture (usually amd64 or arm64).
If you're switching away from multiarch completely, you can also optionally update your /etc/apt/sources.list and sources.d files to specify architecture explicitly:
deb [arch=amd64] http://deb.debian.org/debian bookworm main contrib non-freeThis prevents apt from trying to fetch packages for architectures you no longer support. However, this is optional and not required to remove the architecture.
On systems with SELinux enabled (some distributions), you may encounter additional permission issues. If so, check that your user has proper sudo access and that the dpkg database in /var/lib/dpkg has correct permissions.
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