Question

apt-get update error - W: Failed to fetch mirrors / Some index files failed to download. They have been ignored, or old ones used instead

Posted February 24, 2016 95.9k views
Linux BasicsUbuntuServer OptimizationSecurityIPv6Linux Commands

Hello there,

When I log in to my droplet and execute the following command:

apt-get update

I get the following:

Err http://repo.mysql.com trusty InRelease

Err http://ppa.launchpad.net trusty InRelease

Err http://repo.mysql.com trusty Release.gpg
  Could not resolve 'repo.mysql.com'
Err http://ppa.launchpad.net trusty Release.gpg
  Could not resolve 'ppa.launchpad.net'
Err http://security.ubuntu.com trusty-security InRelease

Err http://security.ubuntu.com trusty-security Release.gpg
  Could not resolve 'security.ubuntu.com'
Err http://mirrors.digitalocean.com trusty InRelease

Err http://mirrors.digitalocean.com trusty-updates InRelease

Err http://mirrors.digitalocean.com trusty Release.gpg
  Could not resolve 'mirrors.digitalocean.com'
Err http://mirrors.digitalocean.com trusty-updates Release.gpg
  Could not resolve 'mirrors.digitalocean.com'
Reading package lists... Done
W: Failed to fetch http://mirrors.digitalocean.com/ubuntu/dists/trusty/InRelease

W: Failed to fetch http://mirrors.digitalocean.com/ubuntu/dists/trusty-updates/InRelease

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/trusty-security/InRelease

W: Failed to fetch http://repo.mysql.com/apt/ubuntu/dists/trusty/InRelease

W: Failed to fetch http://ppa.launchpad.net/ondrej/php5-5.6/ubuntu/dists/trusty/InRelease

W: Failed to fetch http://repo.mysql.com/apt/ubuntu/dists/trusty/Release.gpg  Could not resolve 'repo.mysql.com'

W: Failed to fetch http://ppa.launchpad.net/ondrej/php5-5.6/ubuntu/dists/trusty/Release.gpg  Could not resolve 'ppa.launchpad.net'

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/trusty-security/Release.gpg  Could not resolve 'security.ubuntu.com'

W: Failed to fetch http://mirrors.digitalocean.com/ubuntu/dists/trusty/Release.gpg  Could not resolve 'mirrors.digitalocean.com'

W: Failed to fetch http://mirrors.digitalocean.com/ubuntu/dists/trusty-updates/Release.gpg  Could not resolve 'mirrors.digitalocean.com'

W: Some index files failed to download. They have been ignored, or old ones used instead.

How can I fix this?

I don’t know if it is related but I will mention it anyway. Yesterday I did a few changes on my machine. I followed the tutorials from here:

https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-using-iptables-on-ubuntu-14-04

and

https://www.digitalocean.com/community/tutorials/how-to-implement-a-basic-firewall-template-with-iptables-on-ubuntu-14-04

Please help!

8 comments

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
8 answers

It looks like you broke DNS connectivity with your droplet, as it appears to be unable to resolve domain names. I would roll back the changes you made to your firewall. You would then review your firewall rules to make sure outgoing traffic is allowed back in.

can you check your /etc/resolv.conf file? This might be a dns issue. Preferably I like to use public dns, so I would check whats in the file and if they are not
nameserver 8.8.8.8
nameserver 4.2.2.2

I’d comment them out and add the above

  • I checked:

    sudo nano /etc/resolv.conf

    I have only nameserver 8.8.8.8, so I added:

    nameserver 4.2.2.2

    Saved, Closed. I ran the command:

    sudo apt-get update

    Same errors…

I want to thank to everyone who took part of this discussion trying to help me to find a solution.

For those who want to know it, here are the steps:
1) Go to:

sudo nano /etc/network/interfaces

2) Update the DNS line below:

. . .
iface eth0 inet6 static
        address 2604:A880:0800:0010:0000:0000:00B2:0001
        netmask 64
        gateway 2604:A880:0800:0010:0000:0000:0000:0001
        autoconf 0
        dns-nameservers **8.8.8.8 8.8.4.4**

3) Save, close and refresh your network settigs:

sudo ifdown eth0 && sudo ifup eth0

4) Create a new firewall rule to force IPv4 when it’s available. Create this new file:

sudo nano /etc/apt/apt.conf.d/99force-ipv4

5) Add this single line to the file:

Acquire::ForceIPv4 "true";

6) Save and close the file. Now apt-get update will work! ;)

I Wish the commenter’s would actually try to visit failed URL’s… it looks like at least some of the DigitalOcean mirror for trusty is 404’d

http://mirrors.digitalocean.com/ubuntu/dists/trusty-updates/main/binary-amd64/Packages

no clue how long this has been true for, but it certainly is now

nameserver 127.0.1.1
will this work

what would be the solution for this error then ?

W: Failed to fetch http://ppa.launchpad.net/ondrej/php5-5.6/ubuntu/dists/trusty/main/binary-amd64/Packages  404  Not Found

W: Failed to fetch http://ppa.launchpad.net/ondrej/php5-5.6/ubuntu/dists/trusty/main/binary-i386/Packages  404  Not Found

when i did in server ubuntu 16.00 was not able to update, why ?

how to fix this
root@RMXE:~# apt-get update
Ign http://old.kali.org moto/non-free Translation-en_US
Ign http://old.kali.org moto/non-free Translation-en
Fetched 37.2 MB in 1min 26s (433 kB/s)
W: Failed to fetch http://packagecloud.io/AtomEditor/atom/any/dists/any/main/binary-amd64/Packages 301 Moved Permanently [IP: 50.97.198.58 80]

E: Some index files failed to download. They have been ignored, or old ones used instead.

Submit an Answer