vanarie's picture

Recently APT-GET started having problems resolving to install packages.

The fix is easy:

1) Add this to the end of file /etc/hosts

2) Restart network from the command line: 

#/etc/init.d/networking restart
Liraz Siri's picture

If Ubuntu ever move the server to another address those IP addresses will be broken so its best to solve this problem by using a reliable DNS server, like Google's:
You can configure the nameserver in the configuration console if you configure your address with a static IP. You can also add it to /etc/resolv.conf but if you later use the configuration console those changes might get overwritten.
JP's picture

Hi all,

  Liraz Siri's comment is important.  I had same problem, and the original solution worked (kudos and thanks to vanarie).

However, the root of the problem was not the network of my server, but the fact that my VPN client had overwritten resolv.conf

Adding proper nameservers like Liraz mentioned solved the root of the problem.




Guest's picture

he thanks for the fix you doing fine .how eo you do that?
Helder's picture

I fix this problem changing the order in the file /etc/nsswitch.conf, line host. Put the option dns in the beginning ( I put after files ).

hosts:          files dns wins mdns4_minimal [NOTFOUND=return] mdns4



Chris's picture

I realize this is a very old thread but this finally fixed my issue.  I moved 'dns' right after 'files' and I can now update and install packages.

Girish S's picture

Hi vanarie

Thanks for your inputs. It helped me fix the same problem in virtualbox setup having ubuntu guest OS.


Girish S

gary's picture

just installed ubuntu lots of problems have to reboot machine several times to get to desktop and when i finally do and download updates it will only install 40% and stops at configuring hpijs tired of messing with it any help befor i strip it off my machine and find something else

Jeremy Davis's picture

Do you mean one of the Ubuntu based Turnkey Linux appliances? If not you're not in the right place... I suggest that you try the Ubuntu forums (or at least start a new forum thread in the 'general' section because it doesn't apply to this thread). TKL appliances don't have a desktop (they are server appliances).

If you do mean TKL then you need to supply a bit more info. perhaps post some screenshots of something.

Jaspreet's picture

thank you . you saved me a lot of time .... :) cheers ..

D. Scott's picture

Solved the problem! Thanks!

mike's picture

This worked for me!! (First solution). I was so scared that something wrong was with my OS...but this saved me. Thanks a bunch!

Emil's picture

I have come across the same error. Unfortunately Vanarie's solution is not working anymore
Jeremy Davis's picture

Better to fix the actual problem (which is likely DNS resolution). As Liraz writes (2nd post in this thread) if you use a reliable DNS server, you shouldn't have these sort of issues anyway...

madhav's picture

Hi, I am facing this issue, i have installed ubuntu 18.04 in virtual machine 6.0, unfortunately above steps are not working for me. could someone please help to resolve this issue.?   Error:   root@velpucha-VirtualBox:/home/velpucha# apt-get update Err:1 bionic-security InRelease   Could not resolve '' Err:2 bionic InRelease   Could not resolve '' Err:3 bionic-updates InRelease   Could not resolve '' Err:4 bionic-backports InRelease   Could not resolve '' Reading package lists... Done W: Failed to fetch  Could not resolve '' W: Failed to fetch  Could not resolve '' W: Failed to fetch  Could not resolve '' W: Failed to fetch  Could not resolve '' W: Some index files failed to download. They have been ignored, or old ones used instead.    
Jeremy Davis's picture

This is really old thread (back when TurnKey Linux was based on Ubuntu). We've since moved to a Debian base (~7 years ago) as IMO it has better security and stability.

Regardless, it sounds like you are having network issues of some sort. I'd recommend checking the network setup you are using for your VM and/or VirtualBox in general, plus the networking configuration of your host. Beyond that, your best bet would probably be to post somewhere where there are Ubuntu experts. E.g.:

  • Good luck.

    Renata S.'s picture

    The solution proposed by Helder (changing the order of strings in file   /etc/nsswitch.conf , on the line beginning with "hosts:") still worked for me (despite this thread being quite old). In my case, the line that worked was: "hosts:          files dns mdns4_minimal [NOTFOUND=return] myhostname" (I only moved 'dns' after 'files', and left the rest of the line unchanged.)

    Add new comment