How to Fix “E: unable to locate package” Error in Debian 9

If you install Debian 9 system using a netinstall CD image, your system probably will not have all the necessary repositories (from which you can install common packages), included in the apt sources list file. This can result into error like “E: unable to locate package package-name”.

In this article, I will explain how to fix the “E: unable to locate package package-name” error in Debian 9 distribution.

Useful Articles to read:

  1. 25 Useful Basic Commands of APT-GET and APT-CACHE for Package Management
  2. 15 Examples of How to Use New Advanced Package Tool (APT) in Ubuntu/Debian

I encountered this error while trying to install openssh-server package on Debian 9 server as shown in the screen shot below.

Package Installation Error on Debian 9
Package Installation Error on Debian 9

When you look into the /etc/apt/sources.list file, the default repositories included are shown in the screen shot below.

Debian 9 Repositories
Debian 9 Repositories

To fix this error, you need to add the necessary Debian software repositories in your /etc/apt/sources.list file:

deb  http://deb.debian.org/debian  stretch main
deb-src  http://deb.debian.org/debian  stretch main
Add Software Repository
Add Software Repository

Save and close the file. Then update the system packages list using the command below.

# apt update 

Now try to install the package which showed an error (for example the openssh-server).

# apt install openssh-server
Install Package on Debian 9
Install Package on Debian 9

Note: If you also want the contrib and non-free components, then add contrib non-free after main like this to /etc/apt/sources.list:

deb  http://deb.debian.org/debian stretch main contrib non-free
deb-src  http://deb.debian.org/debian stretch main contrib non-free

You can find more information about /etc/apt/sources.list file from: https://wiki.debian.org/SourcesList

Finally, also read our recent articles concerning installation of useful packages Debian 9:

  1. How to Install Webmin Control Panel in Debian 9
  2. How to Install LEMP (Linux, Nginx, MariaDB, PHP-FPM) on Debian 9 Stretch
  3. Install LAMP (Linux, Apache, MariaDB or MySQL and PHP) Stack on Debian 9
  4. How to Install MariaDB 10 on Debian and Ubuntu

Thats all! If you have any queries, use the feedback form below to reach us. And remember to stick with Tecmint.com for everything Linux.

If this article helped, with someone on your team.

TecMint Weekly Newsletter
Get the Learn Linux 7 Days Crash Course free when you join 34,000+ Linux professionals reading every Thursday.
Check your email for a magic link to get started.
Something went wrong. Please try again.
TecMint has been free for 14 years. Help keep it that way.
Google AI Overviews and tools like ChatGPT have cut into search traffic for independent tech sites like TecMint. Running this site costs over $2,000 every month for hosting, infrastructure, and paying authors to keep the content accurate and tested.

If this article helped you solve a problem, consider buying a coffee. It helps keep TecMint free, supports the authors, and keeps the project going.
☕ Buy Me a Coffee
Aaron Kili
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

5 Comments

Leave a Reply
  1. Hi, I face the same thing while trying to install tomcat7. I followed your steps and try to change sources.list to it is read only. Can you suggest something that could help?

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.

Free Course
Get a free Linux course before you go.
Subscribe to TecMint Weekly and get the Learn Linux 7 Days Crash Course free. Read by 34,000+ Linux professionals every Thursday.
Something went wrong. Please try again.
Check your email for a magic link to get started.