238
Err http://archive.canonical.com natty InRelease    
Err http://security.ubuntu.com oneiric-security InRelease               
Err http://extras.ubuntu.com natty InRelease                            
Err http://security.ubuntu.com oneiric-security Release.gpg
  Temporary failure resolving ‘security.ubuntu.com’
Err http://archive.canonical.com natty Release.gpg
  Temporary failure resolving ‘archive.canonical.com’
Err http://extras.ubuntu.com natty Release.gpg
  Temporary failure resolving ‘extras.ubuntu.com’
Err http://gb.archive.ubuntu.com oneiric InRelease
Err http://gb.archive.ubuntu.com oneiric-updates InRelease
Err http://gb.archive.ubuntu.com natty-backports InRelease
Err http://gb.archive.ubuntu.com oneiric Release.gpg
  Temporary failure resolving ‘gb.archive.ubuntu.com’
Err http://gb.archive.ubuntu.com oneiric-updates Release.gpg
  Temporary failure resolving ‘gb.archive.ubuntu.com’
Err http://gb.archive.ubuntu.com natty-backports Release.gpg
  Temporary failure resolving ‘gb.archive.ubuntu.com’

Reading package lists... Done
W: Failed to fetch http://gb.archive.ubuntu.com/ubuntu/dists/oneiric/InRelease      
W: Failed to fetch http://gb.archive.ubuntu.com/ubuntu/dists/oneiric-updates/InRelease  
W: Failed to fetch http://gb.archive.ubuntu.com/ubuntu/dists/natty-backports/InRelease  
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/oneiric-security/InRelease  
W: Failed to fetch http://archive.canonical.com/ubuntu/dists/natty/InRelease  
W: Failed to fetch http://extras.ubuntu.com/ubuntu/dists/natty/InRelease  
W: Failed to fetch http://archive.canonical.com/ubuntu/dists/natty/Release.gpg  Temporary failure resolving ‘archive.canonical.com’
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/oneiric-security/Release.gpg  Temporary failure resolving ‘security.ubuntu.com’
W: Failed to fetch http://extras.ubuntu.com/ubuntu/dists/natty/Release.gpg  Temporary failure resolving ‘extras.ubuntu.com’
W: Failed to fetch http://gb.archive.ubuntu.com/ubuntu/dists/oneiric/Release.gpg  Temporary failure resolving ‘gb.archive.ubuntu.com’
W: Failed to fetch http://gb.archive.ubuntu.com/ubuntu/dists/oneiric-updates/Release.gpg  Temporary failure resolving ‘gb.archive.ubuntu.com’
W: Failed to fetch http://gb.archive.ubuntu.com/ubuntu/dists/natty-backports/Release.gpg  Temporary failure resolving ‘gb.archive.ubuntu.com’
W: Some index files failed to download. They have been ignored, or old ones used instead.

This is what I'm seeing when I try to run sudo apt-get update. I did an update on my instance yesterday and am now experiencing this.

18 Answers 18

368

overview

There are two parts to your question:

  • fixing temporary resolve messages
  • fixing the package management issues

Temporary resolve

It is likely that this issue is either:

  • temporary due to your Internet Service Provider not correctly forwarding internet naming (DNS) to either its or external DNS servers, or
  • due to a change in your network has similarly blocked this naming - for example, new router/modem, reconfiguring a switch with a new configuration.

Lets look at the possible DNS resolving issues.

First, temporarily add a known DNS server to your system.

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

Then run sudo apt-get update.

If this fixes your temporary resolving messages then either wait for 24 hours to see if your ISP fixes the issue for you (or just contact your ISP) - or you can permanently add a DNS server to your system:

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

8.8.8.8 is Google's own DNS server.

source

Another example DNS server you could use is OpenDNS - for example:

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

package-management issues

In addition to the temporary resolve issues - you have a few package management issues that need to be corrected - I'm assuming you have tried recently to upgrade from one Ubuntu version to the next recommended version - in your case from Natty (11.04) to Oneiric (11.10)

Open a terminal and type

sudo nano /etc/apt/sources.list

Look for lines that have your a different distribution name in the list than you were expecting - in your case - you have upgraded to oneiric but you have another release name natty

For example, look for lines that look like deb http:/archive.canonical.com/ natty backports

Add a # to the beginning of the line to comment it out - for example

#deb http:/archive.canonical.com/ natty backports

Save and re-run:

sudo apt-get update && sudo apt-get upgrade

You should not have any more release naming errors.

At the time of writing this, possible common release names include lucid, maverick, natty, oneiric, precise, quantal, raring, saucy, trusty, utopic and vivid.

12
  • When one name pops out during the update, you might skip the DNS fiddling and go directly to the sources list.
    – SPRBRN
    Commented Apr 24, 2014 at 15:11
  • Still works perfectly with 15.04 and 15.10
    – lxx
    Commented Jan 7, 2016 at 7:51
  • It is most likely a DNS issue of docker not letting apt-get update succeed.
    – dashesy
    Commented May 2, 2018 at 17:06
  • 9
    echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf > /dev/null This did the job.
    – Shayan
    Commented Jun 11, 2019 at 16:30
  • 2
    Temporarily of course, the problem is back on.
    – Shayan
    Commented Jun 11, 2019 at 20:29
30

You can comment the unresolved repo from the file sources.list found on dir /etc/apt/

After modifying the sources.list, clean the apt-get repo as

apt-get clean

Then update

apt-get update

The error will gone away

3
  • 1
    This is a permanent solution to a temporary DNS problem. If you forget to change it back, software from that repository won't be updated or available for install anymore. Commented Jan 27, 2018 at 13:04
  • 4
    This did not work. Commented Aug 1, 2020 at 18:52
  • 1
    Just puttin' it out there for anyone reading this. Don't do what I did and spend 4 hours trying to figure out why apt isn't working. Check your WiFi settings and make sure the switch is in the on position.
    – J-Cake
    Commented Apr 17, 2022 at 8:49
21

Note that this answer was written for old versions of Ubuntu. Current versions use a local nameserver controlled by D-Bus, for which the diagnosis part of this answer applies, but not the solution. If /etc/resolv.conf contains nameserver 127.0.1.1 or more generally nameserver 127.X.Y.Z, don't modify it.

“Temporary failure resolving …” means that your DNS, i.e. the translation from host names to IP addresses, is not working. Did you reconfigure something on your machine recently? If not, this may be a transient error at your ISP.

Does ping -n 8.8.8.8 show lines like 64 bytes from 8.8.8.8: …? (Press Ctrl+C to stop ping.)

  • If it doesn't, you specifically have an IP connectivity problem. Run traceroute -n 8.8.8.8 and see where it stops: if it's in your home/office, check your networking equipment. If you can reach your ISP, complain to them.
  • If it does, you specifically have a DNS problem. Check the contents of /etc/resolv.conf; there should be a line like nameserver 1.2.3.4 (possibly more than one of them). If the lines are there, there is probably a transient problem within your ISP, and you may be able to work around it by adding nameserver 8.8.8.8 to that file (this declares an extra DNS server, which is provided free of charge by Google). If the first number after nameserver is 127, then there is a DNS relay on your machine (this is a good thing), and you must configure that DNS relay rather than modify /etc/resolv.conf. On modern versions of Ubuntu, there is a DNS relay by default, it's Dnsmasq, and it's controlled by D-Bus.
5
  • 3
    Note: ping 8.8.8.8 -c3 pings only 3 times, you don't need to Ctrl+C then. You may use any number in the parameter, like -c5 , -c1 , -c100 etc.
    – Arda
    Commented Nov 5, 2014 at 20:58
  • nameserver has to be placed with the hostname's machine? Commented Mar 7, 2018 at 17:47
  • @albert The /etc/resolv.conf that matters is the one on the machine you're on. But on modern systems, it just points to the local machine, and if you have DNS troubles, you must work with D-Bus and NetworkManager. Commented Mar 8, 2018 at 7:41
  • You Sir, are a genius! Just saved my day. Thanks Commented Oct 23, 2019 at 3:51
  • Restarting my Ubuntu 22.04 worked for me.
    – TmTron
    Commented Aug 23, 2023 at 14:45
8

I had a similar issue, I tried many suggested solutions, but my issue was gone after I rebooted my VM.

3
  • 1
    This worked for me! Commented Nov 16, 2020 at 14:02
  • 1
    This worked for me too! Commented Jan 4, 2021 at 20:27
  • Note to self: Make sure you're not on VPN either Commented Sep 14, 2021 at 9:17
7

This issue can also be caused by a wrongly named interface. For example a Temporary failure resolving error message can be caused by an interface which is not named eth0 but is incorrectly named eml instead.


Another way to solve the a Temporary failure resolving error message is by choosing a different update server mirror.

  1. Open Software & Updates from the Dash and select Ubuntu Software tab -> from the dropdown menu to the right of Download from: select Other....

    Software & Updates

  2. Click the Select the Select Best Server button to select the best download server.

    Select best server

  3. A series of tests will be performed to find the best mirror for your location.

    enter image description here

  4. Click Choose Server to select the recommended server.

2
  • I can not login to my account due to issues I'm facing with lightdm, I need to update lightdm, can you expand your answer on how to resolve the issue? Thanks.
    – Shayan
    Commented Jun 11, 2019 at 16:24
  • How to start Ubuntu in Console mode
    – karel
    Commented Jun 11, 2019 at 16:59
6

Sometimes, when you are behind a proxy server, it is even necessary, that you generate a apt.conf file in /etc/apt/ and fill it with the specific entries, like:

Acquire::http::proxy "http://<yourproxyserver>:<Port>";
Acquire::https::proxy "http://<yourproxyserver>:<Port>";
Acquire::ftp::proxy "http://<yourproxyserver>:<Port>";

If there is an authentification required, the config file looks like:

Acquire::http::proxy "http://<domain\user>:<password>@<yourproxyserver>:<Port>";
Acquire::https::proxy "http://<domain\user>:<password>@<yourproxyserver>:<Port>";
Acquire::ftp::proxy "http://<domain\user>:<password>@<yourproxyserver>:<Port>";
2
  • Could you be more specific and tell us where to put this apt.conf file?
    – desmond13
    Commented Sep 27, 2021 at 13:44
  • @desmond13 Place it in /etc/apt/
    – stoicfury
    Commented Feb 26, 2023 at 6:34
5

This is a DNS problem. Check your /etc/resolv.conf file.

for example in my case when i had this problem & checked this file , the file was empty! but it should contains your dns-nameserver

mine:

nameserver 192.168.10.x

192.168.10.x is my gateway ip address

3
  • 3
    Welcome to AskUbuntu! If you wanna help, make more verbose answer. I mean, cover most possible scenarios and ways to go or post link to appropriate tutorial.
    – Danatela
    Commented Jul 22, 2013 at 8:19
  • 1
    Could you clarify what one should check in /etc/resolv.conf?
    – papukaija
    Commented Jul 22, 2013 at 9:01
  • Actually this one saved my day! I have a FritzBox and nothing was working because some unknown things happend and everything was messed up. Just had to set the nameserver for me on 192.168.178.1 Commented Nov 28, 2019 at 20:07
5

Once upon a time I've met this exact issue — it was shipped with a container. Having wasted 15 minutes I finally realised it's due to wrongly set permissions for /etc/resolv.conf:

root@4ceb6b9e64bc:/usr/lib/apt# ls -l /etc/resolv.conf
-rw-r-----+ 1 root root 19 Feb 24 06:05 /etc/resolv.conf

The fix is as trivial as chmod 644 of course.

3
  • 1
    All methods above didn't work for me. This works wonders! Thanks a lot! Commented Jun 15, 2021 at 16:58
  • If dchcd.conf has iface defined with dns ip , with correct permission on resolv.conf should never be problematic. We should never touch the resolv.conf at first place. Commented Sep 30, 2021 at 4:58
  • You shouldn't even touch a keyboard in the first place, I'd say. But it's my own opinion only, of course. )
    – poige
    Commented Sep 30, 2021 at 7:42
3

The accepted solution does not work for me. In the first place, only apt-get update warns me about Temporary failure resolving 'foo.com', but when I try with nslookup foo.com or ping foo.com, it works fine!

My incredibly dirty hack/fix for solving this bug, is to add the resolved domains manually to /etc/hosts with this short script:

resolveAptHosts()
{
    mapfile -t hosts < <(
        sed -n -r '/^#/d; s;deb(-src)? (http://|ftp://)?([^/ ]+).*;\3;p'\
        /etc/apt/sources.list | sort | uniq )
    # delete all hosts from /etc/hosts, e.g., from an earlier call
    sudo sed -i -r '/^[0-9]{1,3}(\.[0-9]{1,3}){3}[ \t]+('"$( printf '|%s'\
        "${hosts[@]//./\\.}" | sed 's/^|//' )"')[ \t]*$/d' /etc/hosts
    for host in ${hosts[@]}; do
        ip=$( nslookup "$host" | sed -n -r 's|Address:[ \t]*([0-9.]+).*|\1|p' |
              tail -1 )
        sudo bash -c "echo $ip $host >> /etc/hosts"
    done
}

Now updating should work:

resolveAptHosts && sudo apt-get update

If anyone knows why this workaround works and how to solve this bug for real, I'll be eternally thankful. I also tried using sudo apt-get update -o Acquire::ForceIPv4=true in order to exclude IPv6 resolve problems, but that didn't help either.

2
  • 1
    could be just same as askubuntu.com/a/1318847
    – poige
    Commented Feb 24, 2021 at 23:48
  • sudo apt-get update -o Acquire::ForceIPv4=true this little nugget worked for me thanks!! Commented May 29 at 17:48
0

I experienced similar errors when running apt-get commands. It turns out I had the Software Update Panel open on the console.
This seemed to be blocking the command line apt-get, but I'm not certain.

0

I had this error. Following a tip from Linode support, I commented out all the IPv6 lines in /etc/hosts and then apt-get update started working.

0

For those who are using EC2, remember to check that your security group settings allow outbound connections to the websites you are updating from. You can set All traffic outbound setting and see if it works.

0

I got the same issue in a vmware virtual machine, host and guest both are ubuntu. I solved the issue changing the setting of the virtual machine. Instead of using NAT, I set Bridged. It worked for me

0

Please check the hard-disk memory. My memory was almost full and so I had this error, once memory is cleared I am able to do apt-get update

1
  • "Hard-disk memory" is a confusing expression - do you mean free disk space? Furthermore, this question was answered almost 9 years ago. Commented Oct 16, 2020 at 16:15
0

Just adding another last case check. On my system for some reason when the system date was very out of sync then it resulted in the same dns resolution issues. I had a case where my date was somehow set to the year 2000. to check your date simply use the command date to make sure you are in sync.

0

I'm currently experiencing this very same problem and none of the above solutions worked. I noticed that APT was attempting to download some DEB packages from br.archive.ubuntu.com, which redirects to ubuntu.c3sl.ufpr.br (IPv4 200.236.31.4), but this server is currently down.

So in my case what fixed the issue was to run Synaptic (install it with sudo apt install synaptic -y and then either run it with sudo synaptic or run it directly from the Applications panel), then click on Settings => Repositories => Ubuntu Software => Download from: and select Main server, then click on the Close button and finally click on the Reload button.

In my case, the above procedure caused APT to download the updated list of DEB packages from the main repository server archive.ubuntu.com instead of from the server located in my country.

0

one possible cause of the error messages is you do not have an internet connection. You can see these same error messages if during initial ubuntu install you chose to not perform updates (did not connect to wifi/ethernet) which after install finished and you reboot can leave you at endless ubuntu login animation screen (watching those moving dots) ... You will see above error messages if you now boot into Recovery and at root prompt issue apt-get update even after you enable networking from Recovery which does not allow you to connect to wifi if you avoided wifi during initial install.

Solution to this particular edge case : plug in an ethernet cable then boot into Recovery and issue apt-get update or else reinstall from scratch and assure you enable updates

core issue - if you did not connect to wifi during install so you avoided package updates you will not be given a wifi login prompt during Recovery boot - this should get fixed ... also above error messages should suggest possible cause being you do not have an internet connection

2
  • > The error messages should be saying you do not have an internet connection. This is wrong. I have the message "Temporary failure resolving..." in apt but everything else works without problems, so I have an Internet connection. Commented Oct 7, 2021 at 16:55
  • If stil someone facing problem with apt update try this post it was useful to me Commented Jun 1, 2022 at 8:43
0

After installing Ubuntu, I was surprised to find that the other commenters were correct -- networking was disabled when I dropped to the command line from the Grub menu, although I had connected to the network during the installation process.

After unsuccessfully screwing around with the resolv.conf file, I discovered that the solution was right there in the Grub menu: "Enable networking". That fixed everything, and I was able to install updates.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .