apt-get fails to fetch

Asked by Rodolfo Aramayo on 2012-05-18

When trying to use apt-get on a FRESH Ubuntu server installation that has been properly configured for internet use I get:

#############################################################
:~# apt-get update
Err http://us.archive.ubuntu.com precise InRelease

Err http://us.archive.ubuntu.com precise-updates InRelease

Err http://us.archive.ubuntu.com precise-backports InRelease

Err http://security.ubuntu.com precise-security InRelease

Err http://extras.ubuntu.com precise InRelease

Err http://extras.ubuntu.com precise Release.gpg
  Temporary failure resolving 'extras.ubuntu.com'
Err http://security.ubuntu.com precise-security Release.gpg
  Temporary failure resolving 'security.ubuntu.com'
Err http://us.archive.ubuntu.com precise Release.gpg
  Temporary failure resolving 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com precise-updates Release.gpg
  Temporary failure resolving 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com precise-backports Release.gpg
  Temporary failure resolving 'us.archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/InRelease

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-updates/InRelease

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-backports/InRelease

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/InRelease

W: Failed to fetch http://extras.ubuntu.com/ubuntu/dists/precise/InRelease

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/Release.gpg Temporary failure resolving 'us.archive.ubuntu.com'

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-updates/Release.gpg Temporary failure resolving 'us.archive.ubuntu.com'

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-backports/Release.gpg Temporary failure resolving 'us.archive.ubuntu.com'

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/Release.gpg Temporary failure resolving 'security.ubuntu.com'

W: Failed to fetch http://extras.ubuntu.com/ubuntu/dists/precise/Release.gpg Temporary failure resolving 'extras.ubuntu.com'

W: Some index files failed to download. They have been ignored, or old ones used instead.
#############################################################

I have tried to fix the issue as suggested in:
#############################################################
https://help.ubuntu.com/community/PackageManagerTroubleshootingProcedure
#############################################################

But the problem persists. The output of the above commands is:
#############################################################
:~# sudo fuser -vvv /var/lib/dpkg/lock
:~# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04 LTS"
:~# uname -a
Linux genomics07 3.2.0-23-generic #36-Ubuntu SMP Tue Apr 10 20:39:51 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
:~# sudo rm /var/lib/apt/lists/lock
:~# sudo cp -arf /var/lib/dpkg /var/lib/dpkg.backup
:~# sudo mv /var/lib/dpkg/status /var/lib/dpkg/status-bad
:~# sudo cp /var/lib/dpkg/status-old /var/lib/dpkg/status
:~# sudo mv /var/lib/dpkg/available /var/lib/dpkg/available-bad
:~# sudo cp /var/lib/dpkg/available-old /var/lib/dpkg/available
:~# sudo rm -rf /var/lib/dpkg/updates/*
:~# sudo rm -rf /var/lib/apt/lists
:~# sudo rm /var/cache/apt/*.bin
:~# sudo mkdir /var/lib/apt/lists
:~# sudo mkdir /var/lib/apt/lists/partial
:~# LANG=C;sudo apt-get clean
:~# LANG=C;sudo apt-get autoclean
Reading package lists... Done
Building dependency tree
Reading state information... Done
:~# LANG=C;sudo apt-get --purge autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
4 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up grub2-common (1.99-21ubuntu3) ...
Setting up grub-pc-bin (1.99-21ubuntu3) ...
Setting up grub-pc (1.99-21ubuntu3) ...
Installation finished. No error reported.
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.2.0-23-generic
Found initrd image: /boot/initrd.img-3.2.0-23-generic
Found memtest86+ image: /memtest86+.bin
done
Setting up grub-gfxpayload-lists (0.6) ...
:~# LANG=C;sudo apt-get update -o APT::Cache-Limit=25165824
Err http://us.archive.ubuntu.com precise InRelease

Err http://us.archive.ubuntu.com precise-updates InRelease

Err http://us.archive.ubuntu.com precise-backports InRelease

Err http://security.ubuntu.com precise-security InRelease

Err http://extras.ubuntu.com precise InRelease

Err http://security.ubuntu.com precise-security Release.gpg
  Temporary failure resolving 'security.ubuntu.com'
Err http://us.archive.ubuntu.com precise Release.gpg
  Temporary failure resolving 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com precise-updates Release.gpg
  Temporary failure resolving 'us.archive.ubuntu.com'
Err http://extras.ubuntu.com precise Release.gpg
  Temporary failure resolving 'extras.ubuntu.com'
Err http://us.archive.ubuntu.com precise-backports Release.gpg
  Temporary failure resolving 'us.archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/InRelease

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-updates/InRelease

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-backports/InRelease

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/InRelease

W: Failed to fetch http://extras.ubuntu.com/ubuntu/dists/precise/InRelease

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/Release.gpg Temporary failure resolving 'us.archive.ubuntu.com'

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-updates/Release.gpg Temporary failure resolving 'us.archive.ubuntu.com'

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-backports/Release.gpg Temporary failure resolving 'us.archive.ubuntu.com'

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/Release.gpg Temporary failure resolving 'security.ubuntu.com'

W: Failed to fetch http://extras.ubuntu.com/ubuntu/dists/precise/Release.gpg Temporary failure resolving 'extras.ubuntu.com'

W: Some index files failed to download. They have been ignored, or old ones used instead.
:~# sudo dpkg --configure -a
:~# sudo dpkg --clear-avail
:~# LANG=C;sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
:~# LANG=C;sudo apt-get --fix-missing install
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
:~# LANG=C;sudo apt-get update -o APT::Cache-Limit=25165824 && sudo apt-get dist-upgrade
Err http://us.archive.ubuntu.com precise InRelease

Err http://us.archive.ubuntu.com precise-updates InRelease

Err http://us.archive.ubuntu.com precise-backports InRelease

Err http://security.ubuntu.com precise-security InRelease

Err http://extras.ubuntu.com precise InRelease

Err http://extras.ubuntu.com precise Release.gpg
  Temporary failure resolving 'extras.ubuntu.com'
Err http://security.ubuntu.com precise-security Release.gpg
  Temporary failure resolving 'security.ubuntu.com'
Err http://us.archive.ubuntu.com precise Release.gpg
  Temporary failure resolving 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com precise-updates Release.gpg
  Temporary failure resolving 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com precise-backports Release.gpg
  Temporary failure resolving 'us.archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/InRelease

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-updates/InRelease

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-backports/InRelease

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/InRelease

W: Failed to fetch http://extras.ubuntu.com/ubuntu/dists/precise/InRelease

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/Release.gpg Temporary failure resolving 'us.archive.ubuntu.com'

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-updates/Release.gpg Temporary failure resolving 'us.archive.ubuntu.com'

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-backports/Release.gpg Temporary failure resolving 'us.archive.ubuntu.com'

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/Release.gpg Temporary failure resolving 'security.ubuntu.com'

W: Failed to fetch http://extras.ubuntu.com/ubuntu/dists/precise/Release.gpg Temporary failure resolving 'extras.ubuntu.com'

W: Some index files failed to download. They have been ignored, or old ones used instead.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
#############################################################

Any help will be appreciated

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu apt Edit question
Assignee:
No assignee Edit question
Solved by:
actionparsnip
Solved:
2012-05-18
Last query:
2012-05-18
Last reply:
2012-05-18

try running:

echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf > /dev/null

Then try:

sudo apt-get update

Again....

Rodolfo Aramayo (raramayo) said : #2

So I did that and it worked!..Thanks!

But now at the end of the output from: 'sudo apt-get update' I get:

Hit http://us.archive.ubuntu.com precise/restricted Translation-en
Hit http://us.archive.ubuntu.com precise/universe Translation-en
Hit http://us.archive.ubuntu.com precise-updates/main Translation-en
Hit http://us.archive.ubuntu.com precise-updates/multiverse Translation-en
Hit http://us.archive.ubuntu.com precise-updates/restricted Translation-en
Hit http://us.archive.ubuntu.com precise-updates/universe Translation-en
Hit http://us.archive.ubuntu.com precise-backports/main Translation-en
Hit http://us.archive.ubuntu.com precise-backports/multiverse Translation-en
Hit http://us.archive.ubuntu.com precise-backports/restricted Translation-en
Hit http://us.archive.ubuntu.com precise-backports/universe Translation-en
Ign http://extras.ubuntu.com precise/main Translation-en_US
Ign http://extras.ubuntu.com precise/main Translation-en
Fetched 72 B in 1s (36 B/s)
Reading package lists... Done
W: GPG error: http://extras.ubuntu.com precise Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 16126D3A3E5C1192

Ideas?
Thanks

Rodolfo Aramayo (raramayo) said : #3

Thanks actionparsnip, that solved my question.

Luv Latchan (luv-latchan) said : #4

Thanks this also helped me out. I thought I was going crazy then some how came across this post and sorted all my issues.

This works for me as well BUT I have to run echo
nameserver 8.8.8.8" | sudo tee /etc/resolv.conf > /dev/null
every time I reboot the system..

Is there a solution that fixes this once and for all?

Then use:

echo "nameserver 8.8.8.8" | sudo tee /etc/resolvconf/resolv.conf.d/base > /dev/null

Reboot to test

works like a charm. thank you!

Could you explain what that command does?

echo returns the words "nameserver 8.8.8.8" ... which are then stored in /dev/null
??

I am a little confused and like to learn why something fixes an error ;-)

Rodolfo Aramayo (raramayo) said : #8

I know that the original problem was generated when I mistakenly misconfigured my Ubuntu installation when I added the Google DNS servers as:
8.8.8.8,8.8.4.4
When in reality I was supposed to type:
8.8.8.8 8.8.4.4
The presence of the 'comma' in-between made the difference
Now in a GUI is easy to fix this problem post installation, but on the server side I am still trying to find exactly where I should change these values as I am sure that there is a way to change them permanently
In my case, I could afford the luxury of re-installing my system and correcting this annoying error because it is true that after reboot the first solution proposed was being reset
I guess if we find out where Ubuntu writes the DNS values we should be OK

The command output the text to stdout, then it is piped to the tee command to add it to the file, tee also outputs the stdou so I pipe that to /dev/null for neatness.