How do I troubleshoot a missing or broken package manager in my Amazon EC2 Linux instance?
I want to install a package on my Amazon Elastic Compute Cloud (Amazon EC2) Linux instance. However, installation failed, and I received an error message that the package manager binary wasn't found.
Short description
If the package manager is missing or broken, then you might receive the following error messages when you install a package:
- "yum: command not found"
- "apt-get: No such file or directory"
- "Could not retrieve mirrorlist"
- "Failed to synchronize cache"
- "dpkg was interrupted"
- "rpmdb: Thread/process failed"
- "Error: rpmdb open failed"
- HTTP 403 errors
To troubleshoot these errors, repair or restore the broken package manager. If the package manager is missing, then reinstall it.
Note: If the system-release package is missing on Amazon Linux 2023 (AL2023) EC2 instances, then you can't update or install your packages.
Resolution
Note: Amazon Linux 2 (AL2) reached its end of life on June 30, 2026. If you run AL2, then migrate to AL2023 to maintain a supported version. For commands, AL2 uses yum and AL2023 uses dnf.
Repair the broken package manager
For Red Hat Enterprise Linux (RHEL) systems that use yum and dnf, complete the following steps:
-
Run the following command to clear the package manager cache:
sudo dnf clean allNote: For AL2, replace dnf with yum.
-
Run the following command to rebuild the package manager database:
sudo rpm --rebuilddb -
Run the following command to confirm that the package manager works as expected:
sudo dnf checkNote: For AL2, replace dnf with yum. In the output, check for error messages.
For Debian-based systems that use apt, complete the following steps:
-
Run the following command to fix broken dependencies:
sudo apt --fix-broken install -
Run the following command to clear the package manager cache:
sudo apt clean sudo apt autoclean -
Run the following commands to update the package lists:
sudo apt update
If your package manager is still broken, then proceed to the next section.
Reestablish the package manager's dependency chain
Complete the following steps:
-
Run the following command to check the dnf binary status:
ls /usr/bin/dnf head -1 /usr/bin/dnfNote: For AL2, replace dnf with yum. In the output, note the path. If you receive the "No such file or directory" error message, then proceed to Reinstall the missing package manager.
-
Run the following command to identify the Python packages that are still installed:
rpm -qa | grep python -
Run the following command to check the available Python binaries and their expected symbolic links:
python3 -V ls -l /usr/bin/pyth* ls -l /usr/bin/python -
Run the following command to check your PATH environment variable:
echo $PATHMake sure that the /usr/bin/ path is in PATH.
-
Run the following command to list the contents of /usr/bin to identify the available Python versions:
ls -al /usr/bin -
Run the following command to create a symbolic link from the existing Python installation to the expected location:
ln -s /usr/bin/python3.9 /usr/bin/pythonNote: Replace python3.9 with your installed Python version.
-
Run the following command to clean the package manager cache:
dnf clean allNote: For AL2, replace dnf with yum.
-
Run the following command to confirm that the package manager works as expected:
dnf --versionNote: For AL2, replace dnf with yum.
-
Run the following command make sure that the symbolic link works as expected:
head -1 /usr/bin/dnfNote: For AL2, replace dnf with yum.
-
Run the following command to confirm that the Python packages are still installed:
rpm -qa | grep python
If you still encounter broken package manager issues, then you must restore the server from a backup or rebuild the server.
(Only AL2023) Install missing system-release packages
Complete the following steps:
-
Run the following command to manually configure dnf to use the latest release version:
echo latest | sudo tee /etc/dnf/vars/releasever -
Run the following command to clear the cache to remove corrupted metadata:
dnf clean all -
Run the following command to install the missing system-release package:
dnf install system-release -
Run the following command to confirm that the system-release package is installed:
rpm -q system-release -
Run the following command to test package updates:
dnf upgrade
Reinstall the missing package manager
RHEL-based systems
If dnf or yum is missing but RPM still works, then reinstall the package manager directly from a local RPM file. Complete the following steps:
-
Run the following command from a working instance with the same operating system (OS) version to download the required RPM packages:
yumdownloader dnf python3-dnf libdnfNote: For AL2, replace dnf with yum and python3-dnf with python-urlgrabber.
-
Transfer the RPM files to the affected instance. Or, run the following command to directly install the package manager:
sudo rpm -ivh dnf-*.rpm python3-dnf-*.rpm libdnf-*.rpmNote: If circular dependencies block installation, then run the following commands:
sudo rpm -ivh --nodeps sudo dnf install dnf -
Run the following command to make sure that your instance has the required package:
dnf --version
Debian-based systems
If apt or apt-get is missing but dpkg still works, then complete the following steps to reinstall apt from .deb package:
-
From a working system or from your distribution's package archive, download the apt package and its dependencies. To download the packages, see Ubuntu package searches on the Ubuntu packages website or Packages on the Debian website.
-
Transfer the .deb files to the affected instance. Or, run the following command to directly install dpkg:
sudo dpkg -i apt_*.deb libapt-pkg*.debNote: If you receive a dependency error message, then note the missing packages, and then install them from the package archive. Then, reinstall dpkg.
-
To resolve remaining dependency issues, run the following command:
sudo apt --fix-broken install -
Run the following command to make sure that your instance has the required package:
apt --version
SUSE-based systems
If zypper is missing but RPM is still functional, then complete the following steps to reinstall zypper from the installation media or a downloaded RPM:
- Run the following command to get the zypper and libzypp RPM packages from the SUSE installation:
Note: Replace version with the package version for your OS release. The preceding command checks the SUSE repository for SUSE Linux Enterprise Server (SLES) 15.6. For other versions, update the repository download link. For a list of available versions, see Download distribution/leap on the SUSE website.curl -O https://download.opensuse.org/distribution/leap/15.6/repo/oss/x86_64/zypper-version.x86_64.rpm - To find the correct version, run one of the following commands from a working instance that runs the same OS version:
-or-rpm -qa | grep zypper and rpm -qa | grep libzypp
Note: Downloaded packages are stored in /var/cache/zypp/packages/.zypper download zypper libzypp - Transfer the files to the affected instance. Or, run the following command to directly install the package manager:
Note: If circular dependencies block installation, then run the following command to force the installation without dependency checks:sudo rpm -ivh /tmp/zypper-*.rpm /tmp/libzypp-*.rpm
Resolve the circular dependencies after you resolve your package manager issues.sudo rpm -ivh --nodeps /tmp/zypper-*.rpm /tmp/libzypp-*.rpm sudo zypper install zypper libzypp - Run the following command to make sure that your instance has the required package:
Note: If the command returns a version number, then zypper works as expected.zypper --version
Detach and reattach the Amazon EBS volume to a new instance
If you couldn't reinstall the package manager, then reattach your Amazon Elastic Block Store (Amazon EBS) volume to a new instance. Complete the following steps:
- Stop the affected instance.
- Detach the root EBS volume from the instance.
- Launch a new instance with the same Amazon Machine Image (AMI) as the original instance.
- Attach the root volume to the new instance as a secondary volume.
- Run the following command to mount the secondary volume and access your data:
Note: Replace /dev/xvdf1 with the device name for your attached volume.sudo mkdir /mnt/old-root sudo mount /dev/xvdf1 /mnt/old-root - Copy data or configurations from the original volume to the new instance.
- Run the following command based on your distribution to test the package management tools in the new instance.
RHEL:
Note: Replace package_name with your package name.sudo dnf check sudo dnf repolist sudo dnf install "package_name" && sudo dnf remove "package_name"
Debian:
Note: Replace package_name with your package name.sudo apt update sudo apt list --upgradable sudo apt install -y package_name && sudo apt remove -y package_name - Terminate the original instance, and then delete its root volume.
Related information
How do I install a package that's not available in the repository on my Amazon EC2 Linux instance?
Why can't I install a package onto my Amazon EC2 Linux instance?
- Topics
- Compute
- Tags
- Amazon Linux
- Language
- English

Relevant content
asked 2 years ago
AWS OFFICIALUpdated a month ago