When attempting to fetch updates on my Raspberry Pi with the following command:
sudo apt-get update
I received the following error:
Err http://archive.raspberrypi.org wheezy Release.gpg
Temporary failure resolving ‘archive.raspberrypi.org’
Err http://mirrordirector.raspbian.org wheezy Release.gpg
Temporary failure resolving ‘mirrordirector.raspbian.org’
Reading package lists… Done
W: Failed to fetch http://mirrordirector.raspbian.org/raspbian/dists/wheezy/InRelease
W: Failed to fetch http://archive.raspberrypi.org/debian/dists/wheezy/InRelease
W: Failed to fetch http://archive.raspberrypi.org/debian/dists/wheezy/Release.gpg Temporary failure resolving ‘archive.raspberrypi.org’
W: Failed to fetch http://mirrordirector.raspbian.org/raspbian/dists/wheezy/Release.gpg Temporary failure resolving ‘mirrordirector.raspbian.org’
W: Some index files failed to download. They have been ignored, or old ones used instead.
The inability for a Raspberry Pi to resolve a hostname could be due to a few different issues.
First make sure your Pi has internet connectivity and that necessary firewall ports are open. The easiest way to check this is to enable the desktop on your Pi and use a browser to navigate to the links in the error message. If you are able to browse to these links, you do have internet and your ports are open.
If you have confirmed that your Pi has internet and there are no firewall issues. The issue could be related to DNS.
In my case it was, I was able to resolve this issue by updating the /etc/resolv.conf file. On viewing the /etc/resolv.conf file I could automatically see the problem. I had put my Pi on a static IP address in a different range to the IP address listed as the nameserver in my /etc/resolv.conf file. I updated the /etc/resolv.conf file on my Pi using the following command:
sudo nano /etc/resolv.conf
I added the following lines to the file and saved it. These name servers belong to Google.
I am now able search for updates using the following command:
sudo apt-get update