Amazon EC2 instance can't update or use yum

Viewed 115275

I am using Amazon's tutorial for installing a LAMP server. The first several instructions involve using yum, but every single way I have tried to do it has resulted in the same message. I have found a few other recent questions about the same issue, none of which change anything on my setup.

Here is the message:

Loaded plugins: priorities, update-motd, upgrade-helper
Could not retrieve mirrorlist http://repo.us-east-1.amazonaws.com/latest/main/mirror.list error was
12: Timeout on http://repo.us-east-1.amazonaws.com/latest/main/mirror.list: (28, 'Connection timed out after 10001 milliseconds')


One of the configured repositories failed (Unknown),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:

 1. Contact the upstream for the repository and get them to fix the problem.

 2. Reconfigure the baseurl/etc. for the repository, to point to a working
    upstream. This is most often useful if you are using a newer
    distribution release than is supported by the repository (and the
    packages for the previous distribution release still work).

 3. Disable the repository, so yum won't use it by default. Yum will then
    just ignore the repository until you permanently enable it again or use
    --enablerepo for temporary usage:

        yum-config-manager --disable <repoid>

 4. Configure the failing repository to be skipped, if it is unavailable.
    Note that yum will try to contact the repo. when it runs most commands,
    so will have to try and fail each time (and thus. yum will be be much
    slower). If it is a very temporary problem though, this is often a nice
    compromise:

        yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

 Cannot find a valid baseurl for repo: amzn-main/latest

I have done this same thing before without running into any problems, using the same tutorial, but it was several months ago. I don't know what has changed but my meager experience is keeping me from figuring it out.

27 Answers

Check if your outbound entries are deleted/modified from assigned Security group. Normally Outbound entries are set to "All traffic" and allow any IP.

In my case, outbound was deleted. I again set to "All traffic" and it works.

I had the same problem and the way I solved it, was by allowing inbound traffic for the HTTPS protocol port 443 on the security group of your NAT instance. Most of the repositories use HTTPS protocol. Make sure you haven't missed this.

Loaded plugins: priorities, update-motd, upgrade-helper Could not retrieve mirrorlist http://repo.us-east-1.amazonaws.com/latest/main/mirror.list error was 12: Timeout on http://repo.us-east-1.amazonaws.com/latest/main/mirror.list: (28, 'Connection timed out after 10001 milliseconds')

One of the configured repositories failed (Unknown), and yum doesn't have enough cached data to continue. At this point the only safe thing yum can do is fail. There are a few ways to work "fix" this:

  1. Contact the upstream for the repository and get them to fix the problem.

  2. Reconfigure the baseurl/etc. for the repository, to point to a working upstream. This is most often useful if you are using a newer distribution release than is supported by the repository (and the packages for the previous distribution release still work).

  3. Disable the repository, so yum won't use it by default. Yum will then just ignore the repository until you permanently enable it again or use --enablerepo for temporary usage:

    yum-config-manager --disable <repoid>
    
  4. Configure the failing repository to be skipped, if it is unavailable. Note that yum will try to contact the repo. when it runs most commands, so will have to try and fail each time (and thus. yum will be be much slower). If it is a very temporary problem though, this is often a nice compromise:

    yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
    

Cannot find a valid baseurl for repo: amzn-main/latest

Same error I was also having from last week tried almost everything but not able to install server and start httpd service.

Resolved it by just allowing all traffic IN/OUT to and From Security Group and NACL... try it it will be resolved defiantly.

If you're using NACL on the subnet were the EC2 is located.


Quick fix

You will have to open inbound Ephemeral ports for this yum update.

For example adding the #100 inbound rule below:

enter image description here

Notice that this is still necessary even if the outbound rules allow all traffic:

enter image description here

Why did have to do this?

  1. When yum opens an outbound connection on ports like 80/443 it comes back at a random high port (Ephemeral port).

  2. Network ACLs are stateless (not like Security groups) and will not allow returned connection on the same port by default.


You can read more in here.

Check internet connectivity on your EC2 instance by pinging

ping google.com

You will get response by if you have working internet there. If not then go to etc/resolv.conf file and add below lines in that file:

nameserver 8.8.8.8 nameserver 1.1.1.1 nameserver 1.0.0.1

Now check if internet is working. If yes, you can easily resume you work!!!!

I ran the following command with sudo (can't do yum alone if you're not root) and it fixed the issue.

yum-config-manager --save --setopt=dev.mysql.com_downloads_repo_yum_.skip_if_unavailable=true

 

I had the same problem. In my case, I mistakenly deleted the outbound rules of my security group. Adding outbound rule to allow all traffic solved the problem.

please follow the below step

Step 1 : go to AWS-VPC

Step 2 : find DHCP option

Step 3 : if you dont have any DHCP options create a new DHCP

Step 4 : add domaine name = ap-south-1.compute.internal (if your using other region please use other regionname)

Step 5 : add domain name server = AmazonProvidedDNS

Step 6 : then select your VPC --> actions -->edit your DHCP option set --> Select DHCP set which you just created --> Save

Step 7 : Then Reboot your Instance

Step 8 : Login Your Instance then Just type yum list installed --> It will defiantly give you the list of installed things

Thank you

don't worry this is simple error. this is not connect internet also.

just to create new file with vi editor:

vi /etc/resolv.conf

nameserver 8.8.8.8
nameserver 8.8.4.4

and then type this to quit vi: :wq

I am using the default VPC and DNS host resolution is enabled by default; wasn't my issue. I followed the advice to add the default security group and that resolved my issue.

ACL in your vpc differs from the instances inbound or outbound rules. I see the vpc's acl get people every day multiple times.

check for private hosted zone such as "eu-west-1.s3.eu-west-1.amazonaws.com" and make sure the EC2 has internet , for instance if your EC2 instance is in a private subnet you need to make sure your routes point to a nat gateway or instance.

for me these helped, check

  1. NACL
  2. Security Groups
  3. Routing table

this problem is usually caused by not being able to connect to the internet.

Do the following basic test: ping google.com (ping google), if the answer is no, if you are not pinging it is simple, your server is not connecting to the internet.

To solve this, edit the resolv.conf (nano /etc/resolv.conf) when you open the file you will see that it is empty, in my case here I wrote these lines here:

; generated by /usr/sbin/dhclient-script
search ec2.internal
timeout options:2 attempts:5
name server 172.31.0.2

Do this on yours, save the file, and test the ping again on google.com, if it responds normally, you can run yum update -y and it will work.

Hope this helps.

Go to the security group for which EC2 is configured. And verify the below fields in its Inbound rules.If these below fields are not there then add it by clicking on button Edit inbound rules.

  1. Type-: All traffic
  2. Protocol-: All
  3. Port range-: All
  4. Destination-: 0.0.0.0/0

Hope this would resolve the issue.

Hay! Here is perfect answer i found

go to outbound rules add

All Traffic

That's it

Related