5

Like a bunch of other questions, I can't run apt-get update sometimes. Restarting or waiting for a while makes the problem go away. I never have issues pinging or visiting the respective URLs in a browser.

I've tried every up-voted answer to no avail. What is apt doing that is so different to ping or my browser? For example, when I run apt-get update I see this:

Err:1 https://download.docker.com/linux/ubuntu xenial InRelease
  Could not resolve host: download.docker.com
Err:2 https://deb.opera.com/opera-stable stable InRelease
  Could not resolve host: deb.opera.com
Err:3 http://ppa.launchpad.net/danielrichter2007/grub-customizer/ubuntu xenial InRelease
  Could not resolve 'ppa.launchpad.net'
Err:4 http://ppa.launchpad.net/saiarcot895/myppa/ubuntu xenial InRelease
  Could not resolve 'ppa.launchpad.net'
Err:5 http://ppa.launchpad.net/yannubuntu/boot-repair/ubuntu xenial InRelease
  Could not resolve 'ppa.launchpad.net'
Err:6 http://repository.spotify.com stable InRelease
  Could not resolve 'repository.spotify.com'
Err:7 http://dl.google.com/linux/chrome/deb stable InRelease
  Could not resolve 'dl.google.com'
Err:8 http://archive.ubuntu.com/ubuntu xenial InRelease
  Could not resolve 'archive.ubuntu.com'
Err:9 http://archive.ubuntu.com/ubuntu xenial-updates InRelease
  Could not resolve 'archive.ubuntu.com'
Err:10 http://archive.ubuntu.com/ubuntu xenial-backports InRelease
  Could not resolve 'archive.ubuntu.com'
Err:11 http://archive.ubuntu.com/ubuntu xenial-security InRelease
  Could not resolve 'archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial/InRelease  Could not resolve 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-updates/InRelease  Could not resolve 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-backports/InRelease  Could not resolve 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-security/InRelease  Could not resolve 'archive.ubuntu.com'
W: Failed to fetch https://download.docker.com/linux/ubuntu/dists/xenial/InRelease  Could not resolve host: download.docker.com
W: Failed to fetch http://ppa.launchpad.net/danielrichter2007/grub-customizer/ubuntu/dists/xenial/InRelease  Could not resolve 'ppa.launchpad.net'
W: Failed to fetch http://dl.google.com/linux/chrome/deb/dists/stable/InRelease  Could not resolve 'dl.google.com'
W: Failed to fetch https://deb.opera.com/opera-stable/dists/stable/InRelease  Could not resolve host: deb.opera.com
W: Failed to fetch http://ppa.launchpad.net/saiarcot895/myppa/ubuntu/dists/xenial/InRelease  Could not resolve 'ppa.launchpad.net'
W: Failed to fetch http://repository.spotify.com/dists/stable/InRelease  Could not resolve 'repository.spotify.com'
W: Failed to fetch http://ppa.launchpad.net/yannubuntu/boot-repair/ubuntu/dists/xenial/InRelease  Could not resolve 'ppa.launchpad.net'
W: Some index files failed to download. They have been ignored, or old ones used instead.

Running ping download.docker.com:

PING d2h67oheeuigaw.cloudfront.net (52.85.41.233) 56(84) bytes of data.
64 bytes from server-52-85-41-233.mel50.r.cloudfront.net (52.85.41.233): icmp_seq=1 ttl=251 time=18.8 ms
64 bytes from server-52-85-41-233.mel50.r.cloudfront.net (52.85.41.233): icmp_seq=2 ttl=251 time=18.4 ms
64 bytes from server-52-85-41-233.mel50.r.cloudfront.net (52.85.41.233): icmp_seq=3 ttl=251 time=19.5 ms

And visiting the page in my browser works fine. How can I make apt-get "just work"?

Here is the contents of my /etc/apt/resolv.conf:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.1.1
search home.gateway
5
  • 1
    try apt-get -o Acquire::ForceIPv4=true update – Arun Jun 17 '17 at 2:32
  • Does /etc/apt/apt.conf exist and if so, is it using a proxy? A quick fix would be to add the lookup info for those servers in /etc/hosts. The down side of that approach would be if the IPs of those servers ever changes. – jones0610 Jun 17 '17 at 2:41
  • @jones0610 it exists. Why can't apt just resolve hostnames like any other applicaton? – quant Jun 17 '17 at 2:52
  • @Arun that first one seems to work. Why is that? – quant Jun 17 '17 at 2:56
  • @arman I "think" it gets created if, at some point, you connect the machine to a proxy server. I've seen this problem before and the addition of apt.conf becomes permanent. I "think" you can safely rename it which should solve your problem. Or make a copy of it and edit the original, commenting out the proxy line. – jones0610 Jun 17 '17 at 3:05
5

Run this command from terminal and you could use apt and apt-get normally in the future :)

echo 'Acquire::ForceIPv4 "true";' | sudo tee /etc/apt/apt.conf.d/99force-ipv4

1
  • do you know the underlyig problem? why does ipv6 not work? – mikezter Nov 7 '17 at 15:57
1

If /etc/atp/apt.conf exists, make a copy of the file and then edit the original to comment out the following line:

Acquire::http::Proxy "http://proxyaddress:proxyport";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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