I have been trying to get this working for a lot of hours now but no success. Here is what I have done-

  1. ping works
  2. Also added nameserver, in etc/resolv.conf as suggested on many forums (I have some of my company's nameservers added along as well)
  3. I have also updated my source.list according to mentioned here- https://www.raspbian.org/RaspbianRepository. I have tried changing it to deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi but hasn't helped.
  4. tried sudo apt-get update, upgrade
  5. Also added my company's proxy servers using export http_proxy

I am trying to install pip- sudo apt-get install python3-pip (any package basically)

Error it is giving

E: Unable to locate package

It was earlier giving connection closed, failed to fetch errors but now is giving above. Please suggest what should be done.

I have tried to ping google.com but it doesn't work.

I have changed /etc/apt/sources.list to stretch now so my sources.list is

deb mirrordirector.raspbian.org/raspbian stretch main contrib non-free rpi

and /etc/apt/sources.list.d/raspi.list is

archive.raspberry.org/raspbian stretch main contrib non-free

Still getting the same error- unable to locate package.

  • wheezy? Why did you put that in the list file? We left that behind 5 years or so ago... Put sources.list and raspi.list back in its original state, then run sudo apt update and add the output to your question
    – Dirk
    Commented Aug 20, 2018 at 14:25
  • I have changed it to stretch now- so my sources.list is- deb mirrordirector.raspbian.org/raspbian stretch main contrib non-free rpi and raspi.list is- archive.raspberry.org/raspbian stretch main contrib non-free. Still getting the same error- unable to locate package Commented Aug 20, 2018 at 14:53
  • sudo apt-update ends with 3 errors as well- 2 failed to fetch errors and the other- some index files failed to download. Commented Aug 20, 2018 at 14:55
  • You say ping works. Does ping google.com also work?
    – Ingo
    Commented Aug 20, 2018 at 16:19
  • @Ingo, you are right. ping google.com doesn't work but ping works. Seems it is not able to resolve DNS. What should be done? Commented Aug 24, 2018 at 15:03

1 Answer 1


First of all: never touch /etc/resolv.conf. It does not help because this file is managed by openresolv and entries will be overwritten. Instead setup the dns server in /etc/dhcpcd.conf. There are some examples with static domain_name_servers= in it.

ping works so we are certain that the internet connection is available. But ping google.com does not work so it is very likely that your domain name resolution does not work. You can check with dig where the problem is. How to do that look at No Internet, can ping to IPs but not hostnames.

You can try to set

static domain_name_servers=

in /etc/dhcpcd.conf. Then restart dhcpcd:

rpi ~$ sudo systemctl restart dhcpcd.service

and check if this works:

rpi ~$ sudo apt update
  • is there a service you need to restart to make these changes take effect? Commented Jul 6, 2019 at 22:31
  • 1
    @AshtonWiersdorf Yes, after modifying /etc/dhcpcd.conf you have to restart dhcpcd. I have updated the answer.
    – Ingo
    Commented Jul 6, 2019 at 22:47
  • Thanks! I figured it out before you posted; I've run sudo service dhcpcd restart, and it seems to work. Is there a difference? Commented Jul 6, 2019 at 23:00
  • @AshtonWiersdorf Yes, there is a difference. Using old style SysV commands like service xxx restart is deprecated and only emulated by systemd. You should use the commands from systemd. It is the leading system.
    – Ingo
    Commented Jul 6, 2019 at 23:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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