- Newest
- Most votes
- Most comments
Hello.
Amazon Linux 2023 uses S3 for its repository, so HTTPS connections to S3 must be allowed for outbound communication.
Is HTTPS allowed in the outbound rules of your security group?
Also, as described in the following document, access to S3 is required, so you will need to configure a NAT Gateway, S3 VPC endpoint, etc. to ensure a communication path to S3.
https://repost.aws/knowledge-center/ec2-al1-al2-update-yum-without-internet
Based on the error message you're seeing, it appears your EC2 instance cannot reach the Amazon Linux repositories to download packages. This is typically a networking issue. Here are several potential causes and solutions:
- Internet Connectivity: Your instance needs internet access to reach the package repositories. In a custom VPC, this requires:
- A properly configured Internet Gateway attached to your VPC
- A route table with a route to the Internet Gateway (0.0.0.0/0 pointing to the IGW)
- A public IP address assigned to your instance
- Security groups that allow outbound traffic
- DNS Resolution Issues: The error suggests DNS resolution might be failing. Ensure that:
- DNS resolution is enabled in your VPC settings
- Your instance can resolve domain names properly
- Repository Configuration: There might be an issue with the repository configuration files:
- For Amazon Linux 2023, check the files in
/etc/yum.repos.d/directory - Verify the contents of
/etc/dnf/vars/awsregion- it should contain your actual region (e.g., "us-east-1") instead of "default"
-
Network ACLs: Check if your network ACLs are blocking outbound traffic needed for package management.
-
Subnet Configuration: Ensure your subnet has the proper route table associations.
To troubleshoot:
- Verify you can ping external domains (e.g.,
ping amazon.com) - Check if the
/etc/dnf/vars/awsregionfile contains the correct region - Try manually editing this file to set the correct region if it shows "default"
- Review your VPC configuration to ensure all networking components are properly set up
If you're using Ubuntu, similar networking principles apply, though the package management system and repository configuration will be different.
Sources
Unable to install services on my instance. Take Two. | AWS re:Post
Manage package and operating system updates in AL2023 - Amazon Linux 2023
Unable to SSH into AWS EC2 Instance – Connection Timed Out & Forgot Credentials | AWS re:Post
answered 6 months ago
Hi, This issue is almost always caused by a lack of outbound internet access from the EC2 instance.
Even though SSH access works, package installation using yum or apt requires outbound connectivity to AWS package repositories hosted on Amazon S3. In a custom VPC, this commonly fails due to missing or incorrect networking configuration.
Root cause: The EC2 instance does not have outbound internet access.
Why SSH works but installs fail:
- SSH connectivity does not guarantee internet access
- yum and apt require access to AWS S3 repository endpoints.
Most common reasons:
- The instance is deployed in a private subnet.
- There is no NAT Gateway or Internet Gateway configured.
- The subnet route table is missing a 0.0.0.0/0 route.
How to fix:
- For a public subnet, attach an Internet Gateway and assign a public IP.
- For a private subnet, create a NAT Gateway and route outbound traffic through it.
- Alternatively, create an S3 VPC Endpoint if internet access is not desired.
Thx
answered 6 months ago
Relevant content
asked 3 years ago
asked 5 years ago
