67

Running sudo apt-get update fails on my server (that has an internet connection). Are the servers temporarily broken, or is my APT misconfigured and using old servers? In short, how do I fix this?

Here's the output:

~$ uname -a
Linux nematode 2.6.28-19-server #66-Ubuntu SMP Sat Oct 16 18:41:24 UTC 2010 i686 GNU/Linux

~$ sudo apt-get update
Err http://us.archive.ubuntu.com jaunty Release.gpg
  Could not resolve 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com jaunty/main Translation-en_US
  Could not resolve 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com jaunty/restricted Translation-en_US
  Could not resolve 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com jaunty/universe Translation-en_US
  Could not resolve 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com jaunty/multiverse Translation-en_US
  Could not resolve 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com jaunty-updates Release.gpg
  Could not resolve 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com jaunty-updates/main Translation-en_US
  Could not resolve 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com jaunty-updates/restricted Translation-en_US
  Could not resolve 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com jaunty-updates/universe Translation-en_US
  Could not resolve 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com jaunty-updates/multiverse Translation-en_US
  Could not resolve 'us.archive.ubuntu.com'
Err http://security.ubuntu.com jaunty-security Release.gpg
  Could not resolve 'security.ubuntu.com'
Err http://security.ubuntu.com jaunty-security/main Translation-en_US
  Could not resolve 'security.ubuntu.com'
Err http://security.ubuntu.com jaunty-security/restricted Translation-en_US
  Could not resolve 'security.ubuntu.com'
Err http://security.ubuntu.com jaunty-security/universe Translation-en_US
  Could not resolve 'security.ubuntu.com'
Err http://security.ubuntu.com jaunty-security/multiverse Translation-en_US
  Could not resolve 'security.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jaunty/Release.gpg  Could not resolve 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jaunty/main/i18n/Translation-en_US.bz2  Could not resolve 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jaunty/restricted/i18n/Translation-en_US.bz2  Could not resolve 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jaunty/universe/i18n/Translation-en_US.bz2  Could not resolve 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jaunty/multiverse/i18n/Translation-en_US.bz2  Could not resolve 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jaunty-updates/Release.gpg  Could not resolve 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jaunty-updates/main/i18n/Translation-en_US.bz2  Could not resolve 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jaunty-updates/restricted/i18n/Translation-en_US.bz2  Could not resolve 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jaunty-updates/universe/i18n/Translation-en_US.bz2  Could not resolve 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jaunty-updates/multiverse/i18n/Translation-en_US.bz2  Could not resolve 'us.archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/jaunty-security/Release.gpg  Could not resolve 'security.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/jaunty-security/main/i18n/Translation-en_US.bz2  Could not resolve 'security.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/jaunty-security/restricted/i18n/Translation-en_US.bz2  Could not resolve 'security.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/jaunty-security/universe/i18n/Translation-en_US.bz2  Could not resolve 'security.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/jaunty-security/multiverse/i18n/Translation-en_US.bz2  Could not resolve 'security.ubuntu.com'
W: Some index files failed to download, they have been ignored, or old ones used instead.
W: You may want to run apt-get update to correct these problems
3
  • 1
    What is the output of cat /etc/resolv.conf?
    – ændrük
    Mar 5, 2011 at 0:30
  • 1
    Check my answer there as it worked for me: askubuntu.com/questions/135932/…
    – m.alaa8
    Jan 19, 2016 at 15:04
  • BTW for me it was temporary network issue I don't know why , either Ubuntu server temporary banned me maybe because I'm using NAT IPv4 on my VPS .
    – Salem F
    Apr 1, 2020 at 4:39

15 Answers 15

63

It sounds like a DNS issue. To fix it, you need to ensure that

/etc/resolv.conf

has good entries for DNS servers.

Google has public DNS servers that you can use.

So for example, you could add the following 2 lines to the top of your /etc/resolv.conf file (these point at the Google DNS servers) as detailed above:

nameserver 8.8.8.8 
nameserver 8.8.4.4

Of course you'd need to be root to change this file, and make a backup before making any changes!

9
  • 2
    Not necessarily a good plan if you need to resolve addresses inside your own network. Fine if all each machine needs to access by name is located beyond your firewall.
    – Ceisc
    Mar 6, 2017 at 21:45
  • @Ceisc - great point. Thanks for mentioning it!
    – brad parks
    Mar 7, 2017 at 2:30
  • 5
    In that file it says "DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN" -- can you address this?
    – jcollum
    Jul 17, 2017 at 20:02
  • 1
    This is the best answer
    – bademba
    Jan 16, 2018 at 10:18
  • 1
    I had issues with updating my packages for weeks and this fixed it :D Thanks
    – Nasta
    Apr 22, 2020 at 9:06
24

Can you resolve any of those hosts from the command line?

jinx:775 Z$ ping us.archive.ubuntu.com
PING us.archive.ubuntu.com (91.189.92.171) 56(84) bytes of data.
64 bytes from cassava.canonical.com (91.189.92.171): icmp_seq=1 ttl=128 time=104 ms

If not, next step is to try host -v:

jinx:776 Z$ host -v us.archive.ubuntu.com
Trying "us.archive.ubuntu.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 14243
;; flags: qr rd ra; QUERY: 1, ANSWER: 8, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;us.archive.ubuntu.com.         IN      A

;; ANSWER SECTION:
us.archive.ubuntu.com.  592     IN      A       91.189.88.31
us.archive.ubuntu.com.  592     IN      A       91.189.88.40
us.archive.ubuntu.com.  592     IN      A       91.189.88.45
us.archive.ubuntu.com.  592     IN      A       91.189.88.46
us.archive.ubuntu.com.  592     IN      A       91.189.92.169
us.archive.ubuntu.com.  592     IN      A       91.189.92.170
us.archive.ubuntu.com.  592     IN      A       91.189.92.171
us.archive.ubuntu.com.  592     IN      A       91.189.88.30

Received 167 bytes from 10.211.55.1#53 in 37 ms
Trying "us.archive.ubuntu.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50130
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;us.archive.ubuntu.com.         IN      AAAA

;; AUTHORITY SECTION:
ubuntu.com.             1800    IN      SOA     ns1.canonical.com. hostmaster.canonical.com. 2011030301 10800 3600 604800 3600

Received 100 bytes from 10.211.55.1#53 in 65 ms
Trying "us.archive.ubuntu.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 54875
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;us.archive.ubuntu.com.         IN      MX

;; AUTHORITY SECTION:
ubuntu.com.             1800    IN      SOA     ns1.canonical.com. hostmaster.canonical.com. 2011030301 10800 3600 604800 3600

Received 100 bytes from 10.211.55.1#53 in 62 ms

Look for errors returned by DNS servers.

4
  • 2
    I should have mentioned that the ping did not resolve either, but that I was able to ping via IP (resolved on a separate machine). Thanks to this help, and the comment by @ændrük, I discovered that somehow my DNS entries were completely useless. Fixing those fixed the problem.
    – Phrogz
    Mar 5, 2011 at 1:54
  • Interesting problem: "host: command not found" But I can't install it using apt without accepting non-verified packages.
    – jhaagsma
    Jul 12, 2016 at 16:50
  • 1
    no actual commands given here to fix. Just to state when it's working it's working correctly. If I can't ping and can't do host -v I'm doomed. What's next? No help whatsoever.
    – davejal
    Aug 21, 2016 at 0:02
  • Running host with the optional DNS server option (host -v us.archive.ubuntu.com 1.1.1.1) can help. More info here: unix.stackexchange.com/questions/685094/…
    – GammaGames
    Nov 1 at 16:35
18

I know this thread is super old, but for anyone still looking on, I solved this problem by disconnecting and reconnecting to wireless access point.

2
  • 1
    this is the correct answer for the bulk of people who see this error ... you are simply not online ... get your WiFi connected and just issue your update command again ... sudo apt-get update && sudo apt-get dist-upgrade Mar 3, 2018 at 21:11
  • Thanks! This worked for me! Awesome simple answer that will probably be the solution for most people :) Jul 9, 2019 at 11:27
11

Often I shove 8.8.8.8 in my /etc/resolv.conf to fix this. Esp when dealing with wonky cheap-cloud-provider-of-the-month (in this case linode) stuff.

cat /etc/resolv.conf

nameserver 8.8.8.8
nameserver 8.8.4.4
#nameserver 72.14.179.5
#nameserver 72.14.188.5

These are Google's public DNS servers. Yes, they probably track the heck out of those logs. But the only site i tend to hit on those servers is git and ubuntu archives.

4

I had this same issue Err on apt-get update ændrük hinted correctly.

I fixed my problem by changing a DNS address manually into the file /etc/resolv.conf to the DNS address of my operator.

Previously it was set to 192.168.0.254 by Ubuntu.

1
  • Yes, as noted in my follow-up comment to the accepted answer, the problem was that my DNS was hosed and needed to be set to good values.
    – Phrogz
    Jul 19, 2011 at 15:55
3

I had a very similar problem in which: sudo apt-get update couldn't finish, and it had errors. I've tried to restart my cable modem, and it worked. You can try restarting your cable modem, too.

3

Turning off my VPN resolved this issue for me.

1
  • 1
    Thank you so much :)
    – Neel0507
    Nov 12, 2021 at 14:20
2

Check on your web browser to see if you can open web page "http://us.archive.ubuntu.com". If yes, then it has to a network proxy settings problem.

Follow following steps on Ubuntu Desktop.

  1. Go to System->Preferences->Network Proxy
  2. Select “Manual Proxy Configuration”
  3. Check “Use the same proxy for all protocols”
  4. HTTP Proxy: , Port:
  5. Hit Details and check “User Authentication”
  6. Put Username and Password and close

After doing this, I was able to resolve these errors.

1
  • are you saying you resolved this by using a proxy ?
    – zinking
    Apr 22, 2013 at 14:24
2

I just had this same issue. Was working on a Virtual Machine and got tired of it constantly changing IP addresses. After setting static IP address, I did not set the DNS Nameservers and could no longer apt-get update. I needed to also add the name servers to the /etc/network/interfaces file. Found information on that here. (How do I set the DNS Name Servers)

Next issue I ran into is that I could not ifdown and then ifup to reset the network interfaces. This code worked for me:

sudo ifdown eth0 && sudo ifup --exclude=lo -a

More information about this problem can be found here. (How to reset the network interfaces)

2

You can edit /etc/resolvconf/resolv.conf.d/base (empty by default) add

nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver YOUR DNS SERVER
2

To avoid DNS problem I had to add to /etc/hosts the IP of servers, for example

echo "91.189.91.24 security.ubuntu.com" >> /etc/hosts 
echo "91.189.91.24 archive.ubuntu.com" >> /etc/hosts
1

very simple:

  1. look for DNS address manually into file /etc/resolv.conf
  2. cd /etc/network/
  3. sudo nano interface
  4. change nameservers
  5. nameservers 8.8.8.8 8.8.4.4 not working with same routers (in my case hitron very bad

company ip routing not working at all )

you have to use ip address from /etc/resolv.conf

or use only your router ip in my case 192.168.1.1

1

I have also solved this problem . simply go to : system settings --> Network Proxy --> Method Automatic --> Apply SYstem Weide--> and put your admin password

1

I know this is a really old post but I just installed Ubuntu 16.10 on a Dell E4310 and I ran into the same issue. I tried following some of the suggestions in this post but nothing worked so I decided to try changing the update server.

So in System Settings> Software & Updates, I changed the server from "Main" to the following: http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive

Now my updates are rolling without issues. Hope this helps.

0

This will only apply to some people, in particular to people working on managed systems who are configured by others.

When running sudo apt update (preferred), or sudo apt-get update, look for the following types of errors:

Err:1 http://archive.ubuntu.com/ubuntu bionic InRelease                                                                                                                                                      
  Could not resolve 'apt-cacher.something1.something2'
Err:2 https://packagecloud.io/github/git-lfs/ubuntu bionic InRelease                                                                                                                                         
  Could not resolve 'apt-cacher.something1.something2'
Err:3 https://download.sublimetext.com apt/stable/ InRelease                                                                                                                                                 
  Could not resolve 'apt-cacher.something1.something2'
...
Reading package lists... Done
Building dependency tree       
Reading state information... Done
8 packages can be upgraded. Run 'apt list --upgradable' to see them.
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease  Could not resolve 'apt-cacher.something1.something2'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease  Could not resolve 'apt-cacher.something1.something2'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-security/InRelease  Could not resolve 'apt-cacher.something1.something2'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease  Could not resolve 'apt-cacher.something1.something2'
...
W: Some index files failed to download. They have been ignored, or old ones used instead.

Notice the 'apt-cacher.something1.something2' part. Grep for this in /etc/apt to see where this phrase might be found:

grep -rn 'apt-cacher\.something1\.something2' "/etc/apt"

For me, I found a result in the file /etc/apt/apt.conf.d/01proxy. This means that my system has an apt proxy configured to re-route apt update and apt install commands through an alternate server. If this alternate server is on a VPN, for instance, it won't be available if you're not VPNed in to that network, and you'll see the errors above.

As a work-around, you can temporarily disable or enable this proxy by simply renaming this file as follows:

# Disable the apt proxy by changing its name to have a ".bak" extension:
sudo mv /etc/apt/apt.conf.d/01proxy /etc/apt/apt.conf.d/01proxy.bak

# Re-enable the apt proxy by removing the foreign ".bak" extension:
sudo mv /etc/apt/apt.conf.d/01proxy.bak /etc/apt/apt.conf.d/01proxy

Now, when on the VPN, you can optionally re-enable the proxy, and when not on the VPN, you can disable the proxy. In this way your sudo apt update and sudo apt install commands will be able to work in both cases.

Not the answer you're looking for? Browse other questions tagged or ask your own question.