Ec2 instance on AWS apt- get not working

28,180

Solution 1

You EC2 instances's Security groups is not configured to let it reach internet. You need to have an Outbound rule for all traffic to 0.0.0.0/0. In EC2-Classic, this is already in place and hence you need not worry. However, if this is in VPC, then you need to add this rule.

Also, Apart from what is said above, could you check whether any iptables rules causing any issue.

Solution 2

Also make sure that if you want to download anything using wget using HTTPS link .Then add Outbound Rule for HTTPS ( Port 443 ) to 0.0.0.0/0

Solution 3

adding outbound rule HTTP TCP 80 0.0.0.0/0 work for me.

Solution 4

I faced same issue because I did not enable nat gateway for private subnet in vpc.

If your machine is in private subnet you'll have to enable nat gateway in route table for that subnet.

It ll look like this after enabled

enter image description here

Share:
28,180

Related videos on Youtube

raheem52
Author by

raheem52

Updated on February 02, 2022

Comments

  • raheem52
    raheem52 over 2 years

    I have Ec2 instance on AWS with Amazon Ubuntu.

    When i try to download any thing, I am unable to do so.

    For Ex:

    ~# apt-get update
    
    0% [Connecting to ap-southeast-1.ec2.archive.ubuntu.com (103.246.148.161)] [Connecting to security.ubuntu.com (91.189.91.15)
    

    Another Ex will be

    ~# wget https://s3.amazonaws.com/aws-cli/awscli-bundle.zip
    
    --2014-04-09 07:27:17--  https://s3.amazonaws.com/aws-cli/awscli-bundle.zip
    Resolving s3.amazonaws.com... 207.171.189.80
    Connecting to s3.amazonaws.com|207.171.189.80|:443...
    

    This remains forever.

    I was able to download files until I created Group and user for AWS Console.

    Please suggest what can be issues here.

  • NikoNyrh
    NikoNyrh over 7 years
    Also make sure you have assigned a public ip to the instance, I just wasted some time until I realized what the issue was.
  • slayedbylucifer
    slayedbylucifer over 7 years
    @NikoNyrh, You do not need a public IP for this purpose. If that is how you got it working, then your doing something completely wrong.
  • NikoNyrh
    NikoNyrh over 7 years
    Without a publicly accessible ip my EC2 instance couldn't even ping google.com or 8.8.8.8, maybe this only happens when being part of a company's VPC. I could SSH in by using the "internal" ip via VPN but couldn't connect out to open internet.
  • nettie
    nettie over 5 years
    If you forgot you can go into the existing subnet and choose "automatically assign public IP"