Fixing "Target Packages is configured multiple times" Error in Ubuntu & Debian Based Linux Distributions

Seeing repository configured multiple times error while updating your system with apt update command? Here's what you can do about it.
Warp Terminal

Recently, when I was updating Ubuntu via command line, I encountered a warning that complained about target package being configured multiple times.

The exact message after running sudo apt update command looked like this:

Fetched 324 kB in 6s (50.6 kB/s)
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
17 packages can be upgraded. Run ‘apt list –upgradable’ to see them.
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list.d/microsoft-edge-dev.list:3 and /etc/apt/sources.list.d/microsoft-edge.list:3

Since I know a few things about how the apt package manager, I can already see the issue.

Here’s the thing. A repository was added to the list of sources twice. This could happen in the same file or in separate files.

The fix is to read the error message (it’s a warning, actually) correctly and edit the file to remove (or comment out) the same lines. You can see that it mentions both the file name and the line number.

So, here in my case, I removed the third line of one of the files and it stopped showing the warning for me. To summarize, here’s what you need to do:

  • Read the error message and find out which line number of what files have the duplicate entry.
  • Use a terminal-based text editor like Nano to edit one of the files and either remove or comment the same line.
  • The solution may require you to be familiar (and comfortable) with basic Linux commands.

But that’s too short an explanation if you are unfamiliar with package management in Ubuntu and Debian.

Understand and fixing the problem of package configured multiple times

It is important to understand the issue in order to fix it. It’s because there is no single command to make it go away. The solution requires a little but effort from your side and you’ll see that the exact command/process may vary for different people.

What causes this issue?

If you read the warning message, you can at least guess that something is configured more than once.

The APT package management works on sources.list. It’s just a text file that contains the information about repositories from where you can download certain packages.

There is a main /etc/apt/sources.list file that contains the details of the official repositories provided by Ubuntu. Then, there is /etc/apt/sources.list.d directory that contains files for additional external repositories.

The norm is that you do not touch the main /etc/apt/sources.list file. You add a new file in /etc/apt/sources.list.d for any additional repositories you add.

apt sources list
Sources list files

The problem arises when trying to install software by reading various tutorials from the internet. You try adding an external repository, it doesn’t work to your liking. You try to add some other repository from some other tutorial and you end up with duplicate entries without even realizing.

To be clear, this is not an error. If you have duplicate entries in the sources list, your system will still be downloading the packages from it. It’s not stopping your system from working as usual. This is why it is a warning message, not an error. It’s just that it expects a repository to be added only once.

Fixing the duplicate repository entries

To fix the issue, you must remove all duplicate entries and leave just one in the system.

That’s easier said than done, especially for beginners. Let me share a few tips and suggestions on that.

Method 1: For Ubuntu desktop users

There is an application called Software & Updates in Ubuntu. Start this application.

software and updates
Go to Software and Updates application

Go to the Other Software tab and see the additional repositories added to your system. The checked ones are active.

You may look through all the checked ones and see if you can spot duplicate entries. If yes, select one of them and hit the remove button.

remove duplicate repositories ubuntu
Identify and remove the duplicate entries, leaving just one repository

You may rerun the update command to see if the problem is fixed. I know it’s not very convenient, but if you want a GUI tool's convenience, you have to do it.

If you cannot spot the duplicate entries, you have to be a detective and investigate it from the error message as explained in the next sections.

Method 2: Remove duplicate entries using command line (if the duplicate error is not in /etc/apt/sources.list file)

Please note the difference between /etc/apt sources.list (main sources file of the system) and /etc/apt/sources.list.d (folder to keep the files for additional repositories).

If the error complains of repeated entries in files under the /etc/apt/sources.list.d folder, use this method.

I’ll show it to you with my example. Follow the method with the details in your own error message.

W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list.d/microsoft-edge-dev.list:3 and /etc/apt/sources.list.d/microsoft-edge.list:3

The above error message tells me that line number 3 of file /etc/apt/sources.list.d/microsoft-edge-dev.list is the same as the line number 3 of the file /etc/apt/sources.list.d/microsoft-edge.list.

It happened because I had Microsoft Edge browser beta version installed. When the stable version was released, I installed it from deb file and it added another entry.

The decision for me is simple, I can delete one of the files and it won’t complain of the duplicate entry. If you are familiar with the Linux command line, you can get the full path of the file and use the rm command with sudo to delete it.

But if you are clueless about Linux terminal, there is a safer approach and that is to comment out the repeated line.

In the terminal, copy the full path of one of the trouble file. For me, it is /etc/apt/sources.list.d/microsoft-edge-dev.list. Use this sudo gedit command like this:

sudo gedit /etc/apt/sources.list.d/microsoft-edge-dev.list

It will open the file in graphical text editor and you can go to the line number the system was complaining about and add a # at the beginning of the line:

disable repository ubuntu
Go to the line number mentioned in the error and add # at the beginning of it

This will treat the line as a comment. Save the file and close the editor. Your problem should stop now.

Method (or use case) 3: When one file is from /etc/apt/sources.list and other is from /etc/apt/sources.list.d directory

The idea is to avoid touching the main /etc/apt/sources.list file.

So if you have duplicate lines in this file and some other file in the /etc/apt/sources.list.d directory, you should edit the file in /etc/apt/sources.list.d folder.

You copy its path and open it with sudo gedit the same way you saw in the previous method.

Method (or use case) 4: When all duplicate entries are in the /etc/apt/sources.list file itself

It’s possible that you added multiple entries in the main /etc/apt/sources.list file. You should not have but you are not familiar with things so you did it. Now it complains about duplicate entroes in the same file.

W: Target Packages (universe/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:16 and /etc/apt/sources.list:53

duplicate entries in sources list
Duplicate entries in /etc/apt/sources.list file

Now, the first thing here is to make a backup of this file with this command:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.back

Next, open the file with Gedit text editor and sudo:

sudo gedit /etc/apt/sources.list

If you want, you can go to Preference in Gedit and display line numbers. It will be easier to see the line numbers.

gedit show line numbers
Show line numbers in Gedit

Now look at the error message again and see which lines it complains about. Go to one of those lines and add the # before it or delete the line altogether.

remove duplicate entry from sources list
Remove duplicate entry from sources list

Save the file and close the editor. That’s it.

Did it help you?

I don’t know if I made things more complicated. I wanted to explain things in detail so that beginners especially could fix the issue without messing up their system.

Do let me know if it worked for you or not. If you still have questions, feel free to ask in the comment section.

About the author
Abhishek Prakash

Abhishek Prakash

Created It's FOSS 11 years ago to share my Linux adventures. Have a Master's degree in Engineering and years of IT industry experience. Huge fan of Agatha Christie detective mysteries 🕵️‍♂️

Become a Better Linux User

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world

It's FOSS

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.