yum or dnf on an EC2 instance cannot download from the Amazon Linux repository
yum update or dnf upgrade hangs and then times outShort answer
Amazon Linux repositories live in S3. An instance in a private subnet reaches them only through an S3 gateway endpoint whose policy allows the repo bucket. On Amazon Linux 2 in an IPv6-only subnet, yum also needs one switch turned off. Check which applies by the Amazon Linux version and the subnet.
Fix it fast
1Find out which cause you have
Find which Amazon Linux you run and whether the subnet has a route to the internet or to an S3 endpoint.
grep -E '^(NAME|VERSION_ID)=' /etc/os-release && sudo dnf repolist2Match what you see, then jump to its fix
- 1
Amazon Linux 2023 in a subnet with no internet route; dnf cannot download repo metadataA restrictive S3 gateway endpoint policy blocks the AL2023 repo bucketFix - 2
Amazon Linux 2 instance with no IPv4 address; yum cannot reach its repositoryAmazon Linux 2 in an IPv6-only subnet needs the https patch service offFix
- 1
What does the error look like?
yum update or dnf upgrade hangs and then times outdnf cannot download repository metadata on an instance with no internet route
Cause 1 of 2
A restrictive S3 gateway endpoint policy blocks the AL2023 repo bucket
1Check
To download packages from the AL2023 repositories the instance needs access to AWS-owned S3 buckets. If the VPC uses an S3 endpoint, its policy must allow the bucket for your Region. Open the endpoint in the VPC console and read its policy.
sudo dnf makecache2Fix
Add the AL2023 repository bucket to the endpoint policy, with your own Region in the ARN.
{
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::al2023-repos-us-east-1-de612dc2/*"
}3Verify
Run the upgrade again from the instance.
sudo dnf upgrade -yConfirmed by docs.aws.amazon.com
Cause 2 of 2
Amazon Linux 2 in an IPv6-only subnet needs the https patch service off
1Check
AL2 instances launched into an IPv6-only subnet must be told to use the http patch service to reach the yum repository over IPv6.
ip -6 addr show scope global2Fix
Connect to the instance and disable the https patch service, then update.
sudo amazon-linux-https disable
sudo yum update3Verify
yum lists and installs updates.
yum check-update; echo $?Confirmed by docs.aws.amazon.com
How do I stop it coming back?
- When you lock down an S3 endpoint policy, add the Amazon Linux repo bucket before you remove NAT or internet access.
- Use the dnf command on AL2023; yum remains as a pointer to dnf.
- Keep a test instance in each subnet type and run dnf check-update there after network changes.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Related fixes
Servers
apt-get does not exist on this EC2 instance
sudo: apt-get: command not found
apt-get belongs to Debian and Ubuntu.
2 causes, each with a fixServers
dnf cannot install MySQL on Amazon Linux 2023
dnf cannot find a mysql-server package on Amazon Linux 2023
Amazon Linux 2023 documents MariaDB, not MySQL, as its database server, with packages named mariadb105 and mariadb105-server.
3 causes, each with a fixServers
Ansible hangs, then times out waiting for the sudo prompt
a playbook using become seems to hang
Ansible ran sudo on the target and never saw the answer it expected.
3 causes, each with a fixServers
Apache on Ubuntu returns 404 Not Found for my site
The requested URL was not found on this server.
On Ubuntu a 404 from Apache usually means the request maps to a path that has no file.
3 causes, each with a fixServers
Apache returns 504 Gateway Timeout when PHP takes too long
Quick requests work, slow ones end in a 504 after a fixed wait
A 504 from Apache means the backend did not answer within the proxy timeout.
2 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fix