How to fix dpkg: regarding filename.deb containing package-name: package-name conflicts with package-name2 in APT

APTINTERMEDIATEMEDIUMUpdated Dec 29, 2025· 312 views

The 'package conflicts with package' error occurs when dpkg detects that two packages cannot be installed simultaneously because they declare mutual conflicts. This typically happens when multiple versions, variants, or incompatible software provide the same functionality. Resolve this by removing the conflicting package first or using apt to resolve dependencies automatically.

Quick fix

Fixes dpkg: regarding filename.deb containing package-name: package-name conflicts with package-name2

dpkg: regarding filename.deb containing package-name:
package-name conflicts with package-name2
  1. Identify the conflicting packages
  2. Understand the conflict reason
  3. Remove the conflicting package (safest approach)
  4. Use apt to handle conflicts automatically
apt — error
dpkg: regarding filename.deb containing package-name:
package-name conflicts with package-name2
dpkg: regarding filename.deb containing package-name: package-name conflicts with package-name2

What this error means

The "package conflicts with package" error in dpkg occurs when you attempt to install a package (.deb file) that has declared a "Conflicts" relationship with another already-installed package. In Debian/Ubuntu package management, a package can declare conflicts with other packages through its control metadata. This is a safety mechanism—two packages cannot be unpacked on the system simultaneously if one explicitly conflicts with the other. Common reasons for conflicts include: - Two different implementations of the same service (e.g., different mail servers or web servers) - Multiple versions of the same software that cannot coexist - Packages that claim the same files, ports, or system resources - Alternative package variants that serve the same purpose When dpkg detects this situation, it refuses to proceed with the installation to prevent system corruption or inconsistent state. The error message names both the conflicting package being installed and the already-installed package it conflicts with.

Typical symptoms

  • Running 'dpkg -i filename.deb' fails with 'conflicts with' error message
  • Package installation halts mid-process with conflict notification
  • apt-get or apt fails when trying to install a package via repository
  • Error explicitly names both the package being installed and the conflicting package
  • The same package works fine on a fresh system without the conflicting package installed
  • Manual installation via dpkg fails but apt suggests dependency solutions

Common causes

  1. Another package that provides the same service is already installed (most common)
  2. Installing a newer or older incompatible version of the same software
  3. Two packages both claim ownership of the same file or system resource
  4. A package explicitly declares it cannot coexist with another via its Conflicts control field
  5. Multiple repository sources providing conflicting versions of the same software
  6. Custom or manually-compiled packages that conflict with official repository versions

How to fix "dpkg: regarding filename.deb containing package-name: package-name conflicts with package-name2"

1Identify the conflicting packages

Read the error message carefully to see which packages are in conflict:

bash
dpkg: regarding filename.deb containing package-name:
package-name conflicts with package-name2

In this example:
- package-name: The package you're trying to install (from the .deb file)
- package-name2: The already-installed package that conflicts with it

List both packages to understand what they do:

bash
# Check if the conflicting package is installed
dpkg -l | grep package-name2

# Get detailed information about each package
apt-cache show package-name
apt-cache show package-name2

# See which files belong to the installed package
dpkg -L package-name2
2Understand the conflict reason

Check the package metadata to see why they conflict:

bash
# View the control information of the .deb file
dpkg-deb -I filename.deb | grep -E "Conflicts|Replaces|Provides"

# View control information of the installed package
apt-cache show package-name2 | grep -E "Conflicts|Replaces|Provides"

Common reasons:
- Both packages provide the same command or service (check the "Provides:" field)
- Both packages contain files with the same path
- One package is meant to replace the other (check the "Replaces:" field)
- The packages implement incompatible versions of the same protocol or format

3Remove the conflicting package (safest approach)

The safest solution is usually to remove the already-installed conflicting package first, then install the new package:

bash
# First, understand what will be removed and why
apt-cache depends package-name2
apt-cache rdepends package-name2

# Remove the conflicting package
sudo apt-get remove package-name2

# Or more aggressively (removes it and packages that depend on it)
sudo apt-get remove --auto-remove package-name2

# Now install the new package
sudo dpkg -i filename.deb

Before removing, check if anything depends on the conflicting package:

bash
# Find packages that depend on the conflicting package
apt-cache rdepends package-name2

# Find packages that this one provides (often important)
apt-cache show package-name2 | grep Provides
4Use apt to handle conflicts automatically

If you're installing from a repository (not a local .deb file), apt can often resolve conflicts automatically:

bash
# Let apt handle dependency and conflict resolution
sudo apt-get install package-name

# apt will either:
# 1. Remove the conflicting package automatically and install the new one
# 2. Suggest alternatives if the situation is ambiguous
# 3. Refuse if there's no safe resolution path

For local .deb files, you can use gdebi (GUI) which handles dependencies better than raw dpkg:

bash
# Install gdebi if not already present
sudo apt-get install gdebi

# Use gdebi to install the .deb (it will handle conflicts/dependencies)
sudo gdebi filename.deb
5Force override conflicts (use with extreme caution)

If you're certain the packages can coexist, you can force dpkg to ignore the conflict. Only use this if you understand the consequences:

bash
# Force dpkg to ignore conflicts (VERY RISKY)
sudo dpkg --force-conflicts -i filename.deb

# Or even more aggressive (overwrite files too)
sudo dpkg --force-all -i filename.deb

Dangers of forcing:
- You may end up with two packages claiming the same files, causing data corruption
- Services may fail to start or behave unpredictably
- dpkg package database may become inconsistent
- Future updates may fail or break the system

Only use --force-conflicts if:
- You're packaging custom software and know exactly what will happen
- You're in a development environment and can rebuild if needed
- You have a recent backup and can recover from mistakes

6Check and repair the package database if installation partially succeeds

If the installation partially succeeded but left the system in an inconsistent state, repair it:

bash
# Configure any packages left in a broken state
sudo dpkg --configure -a

# Fix broken dependencies
sudo apt-get install -f

# Clean up the package cache
sudo apt-get clean

# Verify everything is consistent
sudo apt-get check

# Update package lists
sudo apt-get update

If the system is severely broken:

bash
# Remove the package that was forcibly installed
sudo dpkg -r package-name

# Reinstall the original conflicting package
sudo apt-get install package-name2

# Verify system health
sudo apt-get check
7Install from a repository instead of a local .deb file

If possible, install from the official or configured repositories instead of manually downloading a .deb file. apt is much smarter about resolving conflicts:

bash
# Update package lists
sudo apt-get update

# Install from repository (apt will handle conflicts if possible)
sudo apt-get install package-name

# Check what apt wants to do before confirming
sudo apt-get install -s package-name  # Simulate, don't actually install

If the conflicting package is newer:

bash
# See available versions
apt-cache policy package-name

# Install a specific version
sudo apt-get install package-name=1.2.3

# Or prefer the newest version in a specific distribution
sudo apt-get -t bullseye install package-name

Advanced notes

### Understanding Debian Package Relationships

Debian packages use several relationship fields to define how they interact:

- Depends: Required for correct operation (must be installed)
- Recommends: Strongly suggested but not required
- Suggests: Optional enhancements
- Conflicts: Cannot be installed at the same time
- Replaces: This package supersedes another and can replace its files
- Provides: This package acts as a substitute for the named package

A "Conflicts" declaration is often paired with "Replaces"—the new package conflicts with the old one but declares it will replace the old package's files.

### Why Packages Conflict

File namespace issues: Only one package can own a given file. If both packages contain /usr/bin/mycommand, they implicitly conflict.

Service ports: Two web servers cannot both listen on port 80. Packages detect this and declare conflicts.

Configuration: Some packages manage the same configuration (e.g., default shell, default mail server) and cannot coexist.

API incompatibility: Major version differences may break each other's dependencies or plugins.

### Multiple Package Managers and Conflicts

Never mix dpkg and apt-get:

bash
# Bad: Installing with dpkg then apt
sudo dpkg -i custom.deb
sudo apt-get install something-else  # May break

# Good: Use apt-get consistently
sudo apt-get install something-else

apt (the newer tool) is much smarter about resolving conflicts and dependencies than raw dpkg. Whenever possible, use apt-get or apt instead of dpkg for installation.

### Checking for Hidden Conflicts

Some conflicts are implicit (shared files) rather than explicit (declared in metadata). Check what a package contains before installing:

bash
# See what files a .deb file contains without installing
dpkg -c filename.deb | less

# See what files are already installed in a location
ls -la /usr/bin/ | grep mycommand

# Check which package owns an already-installed file
dpkg -S /usr/bin/mycommand

### Resolving Complex Multi-Package Conflicts

For complex dependency graphs, use aptitude instead of apt-get:

bash
# Install aptitude (interactive dependency resolver)
sudo apt-get install aptitude

# Use interactive mode to resolve conflicts
sudo aptitude install package-name
# aptitude will present multiple solutions and let you choose

Aptitude is particularly good at finding less-obvious solutions when straight apt-get gives up.

### Common Package Conflict Patterns

| Pattern | Reason | Solution |
|---------|--------|----------|
| nginx vs apache2 | Both are web servers | Remove one, install the other |
| openjdk-8 vs openjdk-11 | Multiple Java versions | Multiple can coexist; check "Conflicts" field |
| sendmail vs postfix | Both are mail servers | Pick one mail server |
| exim4 vs other MTAs | Mail transport agents | Only one MTA can deliver locally |
| PHP versions (5.6 vs 7.4) | Incompatible PHP versions | Use php-distro packages to coexist; apt handles this |

### Recovering from Forced Installations

If you used --force-conflicts and the system is now unstable:

bash
# Check the dpkg status
sudo dpkg --audit

# See what packages have issues
sudo apt-get check

# Force apt to fix broken packages
sudo apt-get install -f

# If that doesn't work, mark and remove the problematic package
sudo apt-mark hold package-name
sudo apt-get remove package-name
sudo apt-mark unhold package-name

Frequently asked questions

What does "dpkg: regarding filename.deb containing package-name: package-name con" mean?
deb file) that has declared a "Conflicts" relationship with another already-installed package. In Debian/Ubuntu package management, a package can declare conflicts with other packages through its control metadata. This is a safety mechanism—two packages cannot be unpacked on the system simultaneously if one explicitly conflicts with the other.
How do I fix "dpkg: regarding filename.deb containing package-name: package-name con"?
The 'package conflicts with package' error occurs when dpkg detects that two packages cannot be installed simultaneously because they declare mutual conflicts. This typically happens when multiple versions, variants, or incompatible software provide the same functionality. Resolve this by removing the conflicting package first or using apt to resolve dependencies automatically.
What causes "dpkg: regarding filename.deb containing package-name: package-name con"?
Another package that provides the same service is already installed (most common) Installing a newer or older incompatible version of the same software Two packages both claim ownership of the same file or system resource
Is the "dpkg: regarding filename.deb containing package-name: package-name con" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading