apt-get not working in ec2
I'm running 14.04 LTS on EC2. I was trying to run apt-get update.
ubuntu@splunk:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty
The error that I'm getting is:
ubuntu@splunk:~$ sudo apt-get update
Err http://us.archive.ubuntu.com trusty-security InRelease
Err http://us.archive.ubuntu.com trusty-updates InRelease
Err http://us.archive.ubuntu.com trusty-security Release.gpg
Cannot initiate the connection to us.archive.ubuntu.com:80 (2001:67c:1562::16). - connect (101: Network is unreachable) [IP: 2001:67c:1562::16 80]
Err http://us.archive.ubuntu.com trusty-updates Release.gpg
Cannot initiate the connection to us.archive.ubuntu.com:80 (2001:67c:1562::16). - connect (101: Network is unreachable) [IP: 2001:67c:1562::16 80]
0% [Connecting to archive.ubuntu.com (91.189.88.162)]
I've confirmed my sources and ran the following but it still wasn't working
sudo apt-get autoremove
$ sudo apt-get --purge remove && sudo apt-get autoclean
$ sudo apt-get -f install
$ sudo apt-get update
$ sudo apt-get upgrade && sudo apt-get dist-upgrade
$ sudo dpkg-reconfigure -a
$ sudo dpkg --configure -a
It's not a network issue but I am able to get run wget out to splunk.com on http and DNS resolution is completing.
It was an issue with the firewall that this server routes through. Once we allowed 10.0.0.0/8 :80 out, it worked. I think the wget worked is because 443 was allowed.
It's an easy fix.
Just Go to AWS VPC and select your Route Table, Just add ::/0 >
then execute apt-get update
I had the exact issue described here, and had triple checked my security group (firewall) and still could not access the internet. If you've still having issues like me, there are two other possible causes/solutions depending on your subnet routing:
- if your instance is in a private subnet (one without an 'internet gateway' route), then you'll have this issue. You'll need to setup a NAT gateway and use that as a route for 0.0.0.0/0 if you want it to remain private (see this AWS KB article), or
- if your instance is in a public subnet (that is one with an 'internet gateway' route), and you're still not able to access the internet, then you need to make sure your instance has either an Elastic IP or a Public IP (aka a free non-Elastic IP). Note: Also note, public IP's can only be enabled on instance launch (see this AWS KB article).