Thursday, October 10, 2013

update error on Ubuntu Server 12.04

Recently I came across an annoying error on my headless Ubuntu Server. Nothing really had happened as far as I'm concerned in my home LAN, and all of a sudden only this distro could no longer run an OS update. I did upgrade my internet service recently but I'm not sure if that could be related. Anyway, the error I kept getting for days was:


 
"  temporary failure resolving 'us.archive.ubuntu.com'  "

Err http://us.archive.ubuntu.com precise Release.gpg

Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/Release.gpg

Temporary failure resolving 'us.archive.ubuntu.com'


Anyway, after a bit of googling, I came across a helpful comment by fossfreedom from the UK, which can be found here. The solution was simple for me:

  1. Test to see if the problem is your DNS setting or an ISP issue. To do this type on the console: ping -n 8.8.8.8
  2. If produces replies you can stop it with Ctrl + C. This indicates that it is not an ISP problem so there is no point in calling them.
  3. Therefore, for me it was a DNS problem, which I have been having a lot of lately (likely due to my VPN usage). So I checked /etc/resolv.conf to see if I could find my DNS servers there. That's when I knew what my problem was. The file was empty, so I added the google DNS server.
  4. This was done through: echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf > /dev/null
  5. After that, I just had to run the update via: sudo apt-get update