6

First of all I am new to Linux command line. I never worked with it before. My problem is that the command apt-get update will just return:

Err:1 http://us.archive.ubuntu.com/ubuntu xenial InRelease
  Temporary failure resolving 'us.archive.ubuntu.com'
Err:2 http://us.archive.ubuntu.com/ubuntu xenial-security InRelease
  Temporary failure resolving 'us.archive.ubuntu.com'
Err:3 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease
  Temporary failure resolving 'us.archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/xenial/InRelease  Temporary failure resolving 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/xenial-security/InRelease  Temporary failure resolving 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/xenial-updates/InRelease  Temporary failure resolving 'us.archive.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.

My sources.list file looks like this:

#------------------------------------------------------------------------------#
#                            OFFICIAL UBUNTU REPOS                             #
#------------------------------------------------------------------------------#


###### Ubuntu Main Repos
deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse 
deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse 

###### Ubuntu Update Repos
deb http://us.archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse 
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse 
deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse 
deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse

My ubuntu version is:

Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-66-generic x86_64)
Zanna
  • 70,465
Sandor
  • 63
  • 1
    Do you always face with this problem or it just happened once? It can be because of connection problem. Try it again after few minutes. It should connect. – Mostafa Ahangarha Mar 13 '17 at 13:41
  • Are you running sudo? As in sudo apt-get update ? – Delorean Mar 13 '17 at 16:35
  • Temporary failure resolving 'us.archive.ubuntu.com' That's the root cause of your problem. Can you access http://us.archive.ubuntu.com/ in your browser? Can you access other Web sites? – Joseph Sible-Reinstate Monica Mar 13 '17 at 18:30
  • i've had this happen when my internet service went down or when the wifi connection dropped. after things were working, again, so too apt-get update worked. – Skaperen Sep 09 '17 at 02:12

3 Answers3

18

I had the same issue. The heart of the problem was an inability to resolve DNS. I was missing my /etc/resolv.conf file.

The contents of it should be:

nameserver 8.8.8.8
nameserver 8.8.4.4

Afterwards, restart the correct interface (mine was lo instead of eth0). You can find it in the /etc/network/interfaces file.

  • 1
    i prefer not to show google what sites i browse and use other DNS servers. since i have ipv6 my list uses it: 2001:67c:28a4:: and 2001:470:20::2 – Skaperen Sep 09 '17 at 02:17
  • 3
    you don't need to restart the interface after changing /etc/resolv.conf. you do need to restart continuously running programs that use the resolver, such as firefox. – Skaperen Sep 09 '17 at 02:21
  • How to restart the interface? I notice that every time I add things to /etc/resolv.conf, after restarting returns to origina values. – Joshua Salazar Oct 01 '21 at 09:58
3

I had the same issue, caused by incorrect DNS settings:

sudo nano /etc/network/interfaces

In this file set a correct DNS server: dns-nameservers 8.8.8.8

sudo ifdown eth0 && sudo ifup eth0
pa4080
  • 29,831
Mehdy
  • 31
0

I had this same issue, but a slightly different error message. This worked for me:

sudo nano /etc/network/interfaces

Find the line for dns-nameserver. If you don't have it, add it like this:

dns-nameserver 208.067.222.222

That is the address for OpenDNS. You can also use 8.8.8.8, which is address for Google Public DNS.

wjandrea
  • 14,236
  • 4
  • 48
  • 98
MikeR
  • 41