Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Contrary to the note above, I haven't found the answer to my problem.

I have read almost a dozen apt-get update questions, most from askubuntu.com, with "failed to fetch" errors and tried the solutions answered there. Unfortunately, none worked. I just recently installed Ubuntu 12.04 on my laptop, dual booting it alongside Windows 7. When i tried

sudo apt-get update

on the terminal, the following kept occuring:

Err http://ph.archive.ubuntu.com precise InRelease

Err http://ph.archive.ubuntu.com precise-updates InRelease                     

Err http://ph.archive.ubuntu.com precise-backports InRelease                   

Err http://ph.archive.ubuntu.com precise Release.gpg                           
  Unable to connect to ph.archive.ubuntu.com:http: [IP: 91.189.92.177 80]
Err http://ph.archive.ubuntu.com precise-updates Release.gpg            
  Unable to connect to ph.archive.ubuntu.com:http: [IP: 91.189.92.177 80]
Err http://ph.archive.ubuntu.com precise-backports Release.gpg          
  Unable to connect to ph.archive.ubuntu.com:http: [IP: 91.189.92.177 80]
Err http://extras.ubuntu.com precise InRelease                          

Err http://extras.ubuntu.com precise Release.gpg                        
  Unable to connect to extras.ubuntu.com:http:
Err http://security.ubuntu.com precise-security InRelease

Err http://security.ubuntu.com precise-security Release.gpg
  Unable to connect to security.ubuntu.com:http: [IP: 91.189.92.190 80]
Reading package lists... Done
W: Failed to fetch http://ph.archive.ubuntu.com/ubuntu/dists/precise/InRelease  

W: Failed to fetch http://ph.archive.ubuntu.com/ubuntu/dists/precise-updates/InRelease  

W: Failed to fetch http://ph.archive.ubuntu.com/ubuntu/dists/precise-backports/InRelease  

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

W: Failed to fetch http://extras.ubuntu.com/ubuntu/dists/precise/InRelease  

W: Failed to fetch http://ph.archive.ubuntu.com/ubuntu/dists/precise/Release.gpg      Unable to connect to ph.archive.ubuntu.com:http: [IP: 91.189.92.177 80]

W: Failed to fetch http://ph.archive.ubuntu.com/ubuntu/dists/precise-updates/Release.gpg  Unable to connect to ph.archive.ubuntu.com:http: [IP: 91.189.92.177 80]

W: Failed to fetch http://ph.archive.ubuntu.com/ubuntu/dists/precise-backports/Release.gpg  Unable to connect to ph.archive.ubuntu.com:http: [IP: 91.189.92.177 80]

W: Failed to fetch http://extras.ubuntu.com/ubuntu/dists/precise/Release.gpg  Unable to connect to extras.ubuntu.com:http:

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/Release.gpg  Unable to connect to security.ubuntu.com:http: [IP: 91.189.92.190 80]

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

Note:

This happened immediately after I installed Ubuntu 12.04. I am very new to the Linux/Ubuntu world and a noob when it comes to these kind of stuff.

The Sources list in the Update Manager (and Software Center) settings was short. It only contained 2 lines with "Canonical" in it, 2 lines with "Independent" in it, and 2 other lines. I think the list was short because it was a freshly installed Ubuntu.

Connection to the internet seems fine and my friend whose laptop had just been installed with Ubuntu 12.04 around the same time as mine, seems to have no problem with his update. We share the same connection so I think internet connection issues couldn't have been the reason for the error.

Attempted Solutions:

From here, I explored around /etc/resolvconf/resolv.conf.d and added in the /etc/resolvconf/resolv.conf.d/head the following:

nameserver 8.8.8.8
nameserver 8.8.4.4

Error still occured.

From here and here, I repeatedly changed which Mirror server to use in the Update manager and Software sources settings. Again, error still occured.

I also tried editing my sources list, unchecking the lines with "independent" on it(as suggested). According to here, I tried removing the derb-src lines in the sources list. Still, to no avail.

Lastly, this site suggests running the following:

echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf > /dev/null
or, for a permanent solution,
echo "nameserver 8.8.8.8" | sudo tee /etc/resolvconf/resolv.conf.d/base > /dev/null

Sadly, nothing worked for me. In all forums that I have been to, the answer related to nameserver 8.8.8.8 seems to come up most often. Take note also that I really did not understand the solutions, what they meant or how are they done. I just simply followed them.

This is the output for cat /etc/apt/sources.list:

# deb cdrom:[Ubuntu 12.04 LTS _Precise Pangolin_ - Release amd64 (20120425)]/ dists/precise/main/binary-i386/

# deb cdrom:[Ubuntu 12.04 LTS _Precise Pangolin_ - Release amd64 (20120425)]/ dists/precise/restricted/binary-i386/
# deb cdrom:[Ubuntu 12.04 LTS _Precise Pangolin_ - Release amd64 (20120425)]/ precise main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://archive.ubuntu.com/ubuntu precise main restricted
deb-src http://archive.ubuntu.com/ubuntu precise main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://archive.ubuntu.com/ubuntu precise-updates main restricted
deb-src http://archive.ubuntu.com/ubuntu precise-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://archive.ubuntu.com/ubuntu precise universe
deb-src http://archive.ubuntu.com/ubuntu precise universe
deb http://archive.ubuntu.com/ubuntu precise-updates universe
deb-src http://archive.ubuntu.com/ubuntu precise-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://archive.ubuntu.com/ubuntu precise multiverse
deb-src http://archive.ubuntu.com/ubuntu precise multiverse
deb http://archive.ubuntu.com/ubuntu precise-updates multiverse
deb-src http://archive.ubuntu.com/ubuntu precise-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://archive.ubuntu.com/ubuntu precise-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu precise-backports main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu precise-security main restricted
deb-src http://archive.ubuntu.com/ubuntu precise-security main restricted
deb http://archive.ubuntu.com/ubuntu precise-security universe
deb-src http://archive.ubuntu.com/ubuntu precise-security universe
deb http://archive.ubuntu.com/ubuntu precise-security multiverse
deb-src http://archive.ubuntu.com/ubuntu precise-security multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu precise partner
# deb-src http://archive.canonical.com/ubuntu precise partner

## This software is not part of Ubuntu, but is offered by third-party
## developers who want to ship their latest software.
deb http://extras.ubuntu.com/ubuntu precise main
deb-src http://extras.ubuntu.com/ubuntu precise main

And the following is for cat /etc/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.0.1
search nip.upd.edu.ph

It has been pointed out that the answer is here but unfortunately that didn't work either. I tried choosing different servers but the "choose server" was never available. Searching for the best server yielded a "No suitable server" result. I think the mirror servers are fine and again, there seems to be no issue with internet connection.

Using ping -c3 archive.ubuntu.com and ping -c3 8.8.8.8 both yielded 0% packet loss. The ping for 8.8.8.8 sometimes yielded 33% packet loss but mostly 0%.

Typing nslookup google.com yields

Server:     127.0.0.1
Address:    127.0.0.1#53

Output of ps aux | grep dns:

nobody    1761  0.0  0.0  33012  1284 ?        S    17:04   0:00 /usr/sbin/dnsmasq
 --no-resolv --keep-in-foreground --no-hosts --bind-interfaces --pid-file=/var
/run/sendsigs.omit.d/network-manager.dnsmasq.pid --listen-address=127.0.0.1 --conf-
file=/var/run/nm-dns-dnsmasq.conf --cache-size=0 --proxy-dnssec
joa       2197  0.0  0.0  13576   928 pts/0    S+   17:10   0:00 grep --color=auto dns
share|improve this question
    
Okay, let's just start from scratch. First, can you copy the exact output of the terminal when you type sudo apt-get update? Also, can you include the output of cat /etc/apt/sources.list and cat /etc/resolv.conf? And you confirm that you can browse websites on the internet normally? –  Alaa Ali May 21 '13 at 13:45
    
@Alaa In response to your inquiry, I have edited the question and posted everything you needed to know. And yes, I was able to browse websites on the internet normally. –  jowayow May 21 '13 at 14:27
    
0% packet loss? So you can ping and browse, but you can't resolve in apt-get updates...hmm. Is there some kind of DNS setting that only works with apt-get? Anyways, can you post the first two lines from nslookup google.com, and post the output of ps aux | grep dns? Also, are you using a static IP? –  Alaa Ali May 22 '13 at 8:16
    
@Alaa I have edited the question and posted the outputs. The output for ps aux | grep dns is supposed to be a single line but I edited it to make it easier to view. Initially, I would say that I use a dynamic IP because I haven't paid anything for it, but I use university internet connections so its hard to know if the IP I use is static or dynamic. –  jowayow May 22 '13 at 9:27
    
@Alaa I just verified that I use a dynamic IP. –  jowayow May 22 '13 at 9:40

4 Answers 4

Edit /etc/resolv.conf. In a Terminal window run

sudo gedit /etc/resolv.conf

and add the line

nameserver 8.8.8.8

and save. Then do

ping www.google.com

If this succeeds then run the following commands

sudo apt-get --download-only --reinstall install resolvconf
sudo dpkg --purge --force-depends resolvconf
sudo apt-get install resolvconf

If resolving now fails then right-click on the network indicator in the bar at the top of the desktop, click Edit Connections, select your connection, Click Edit | IPv4 Settings. Change Method from Automatic (DHCP) to Automatic (DHCP) addresses only and enter 8.8.8.8 in the Additional DNS servers field. Click Save.... Verify that /etc/resolv.conf now contains a line nameserver 8.8.8.8 and that you can still ping www.google.com.

share|improve this answer
4  
@guntbert Umm. You are talking to the author of the resolvconf package. I think that he knows what he is talking about. ;-) –  Kevin Bowen May 22 '13 at 9:17
    
@jdthood Previously, I was able to ping 8.8.8.8 (as stated in the question) but after adding the line nameserver 8.8.8.8, it didn't resolve and this line appeared From nat1.up.edu.ph (10.16.1.2) icmp_seq=1 Destination Host Unreachable –  jowayow May 22 '13 at 9:53
    
@jdthood I also edited my connections, changing to Automatic (DHCP) addresses only and adding 8.8.8.8. Yes, /etc/resolv.conf now contains the line nameserver 8.8.8.8 but From nat1.up.edu.ph (10.16.1.2) icmp_seq=1 Destination Host Unreachable still appeared. I reverted all the edits I made to the original configuration but unfortunately it didn't solve the ping problem. –  jowayow May 22 '13 at 9:59
1  
@maggotbrain thx for helping me pull my foot out of my mouth again :-) –  guntbert May 22 '13 at 10:29
1  
@guntbert It's all good, man. Been there, myself. If there are any dns/resolveconf issues, jdthood is the goto man to solve them! –  Kevin Bowen May 22 '13 at 10:52
up vote 3 down vote accepted

sudo apt-get update finally worked! I just realized that the problem was not on the system but instead how the system connects and retrieves data from the internet. I just configured my Network settings and changed the proxy detection to Manual and filled in the HTTP, HTTPS, FTP, and Socks Host blanks the proxy that I use. When I updated again, this error output happened at first:

E: Could not get lock /var/lib/dpkg/lock - open (11 Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/)

Well, not exactly like the same but similar to it (I copied above from here). But when I tried updating again, it finally worked(the reason I posted the error output above and not the exact output I saw) and I can now choose a different mirror server. If the Network proxy configuration was really the reason for my woes, well, I kinda felt stupid for such basic mistake.

Anyway, thanks everybody for your help! :)

share|improve this answer
    
Nice to hear! Please accept your own answer. –  jdthood May 23 '13 at 13:35

I was facing the same problem and figured the easiest solution is to reset the sources of /etc/apt/sources.list. To do so, follow these steps:

  1. Obtain the release of your Ubuntu version, type into the console:

    lsb_release -r

  2. Go to http://repogen.simplylinux.ch/ to generate a new sources.list

  3. Select your country & release
  4. Check the first 12 boxes:

    All Ubuntu Brances + Security & Updates

  5. Generate and copy your new list
  6. Backup the old file to sources.list.old

    mv /etc/apt/sources.list /etc/apt/sources.list.old

  7. Open vim to save the new list

    vi /etc/apt/sources.list

  8. Paste and save using :wq
  9. G2G, retry running apt-get update
share|improve this answer
1  
I decided to answer this, even though the authors problem was solved differently. His question is the top result to a lot of problems related to a corrupted source.list file (stumbled upon it 3 times) and felt to leave my solution here, since it would have saved me a lot of time. –  RienNeVaPlus Jun 6 at 19:59
    
I downloaded a ubuntu 12 virtual machine, and no repos where valid (italian ones). I did this and worked like a charm! thanks! –  Feida Kila Oct 1 at 15:06

Do this

sudo bash -c 'echo "nameserver 127.0.0.1" >> /etc/resolv.conf'

Then do sudo apt-get update to see if it works.

share|improve this answer
    
Nope, sudo apt-get update still doesn't work. Do I have to remove the line nameserver 127.0.01 or it's ok to leave it there? –  jowayow May 22 '13 at 10:19
    
Did you try to do this after reverting from jdthood's answer? So just make sure that you can ping 8.8.8.8, then add the line nameserver 127.0.0.1 to /etc/resolv.conf, it has to be the only line (after the comments of course). –  Alaa Ali May 22 '13 at 10:43
    
Yes, I did this after reverting and there was no issue with ping 8.8.8.8 (Of course, after reverting). Basically, nameserver 127.0.0.1 was the only line added to /etc/resolv.conf. –  jowayow May 22 '13 at 10:59
    
I just wondered, the original /etc/resolv.conf` file already contained nameserver 127.0.0.1 before adding it. When I followed your answer, the edited file now contained to lines of nameserver 127.0.0.1. Is there any reason for this? –  jowayow May 23 '13 at 2:26
    
The command in my answer added the line nameserver 127.0.0.1 regardless of whatever was already in the file. The original file (after a fresh install) should most likely contain that line already, although the output that you had in your question did not have that. But, after you followed the last commands in jdthood's answer, I think the file was reset and the line nameserver 127.0.0.1 was added. So when you followed my answer, another line was added. Anyways, if you have two lines, it's safe to remove one of them. –  Alaa Ali May 23 '13 at 5:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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