How to fix dpkg-query: no packages found matching package-name in APT

APTBEGINNERLOWUpdated Dec 29, 2025· 307 views

The "dpkg-query: no packages found matching" error occurs when you try to query or check a package that isn't installed on your Debian/Ubuntu system. This is typically a lookup error rather than a system failure.

Quick fix

Fixes dpkg-query: no packages found matching package-name

apt-cache search package-name
  1. Verify the exact package name
  2. Update your package lists
  3. Install the missing package
  4. Properly quote wildcard patterns in scripts
apt — error
apt-cache search package-name
dpkg-query: no packages found matching package-name

What this error means

The dpkg-query tool is the database query interface for the Debian Package Manager (dpkg). When you run dpkg-query on a package name, it searches the local installed package database. If the package isn't in that database, dpkg-query reports that no packages match the search pattern. This is different from a package being unavailable in repositories—it specifically means the package isn't currently installed on your system. The error happens at the query stage, before any installation or system interaction occurs.

Typical symptoms

  • Scripts or tools fail when checking if a package is installed
  • dpkg-query command returns exit code 1 with the "no packages found" message
  • Installation scripts or automation fail partway through when probing for package presence
  • Wildcard patterns with dpkg-query don't return expected matches

Common causes

  1. The package you're querying is not installed on the system
  2. The package name is misspelled or uses a different name than expected
  3. The actual package name differs from the program/tool name (e.g., the binary is 'python' but package is 'python3')
  4. Wildcard patterns in dpkg-query are being expanded by the shell before being passed to dpkg-query
  5. Using dpkg-query with an older or incompatible package name format

How to fix "dpkg-query: no packages found matching package-name"

1Verify the exact package name

First, search for the package in your system's package repositories to confirm the correct name:

bash
apt-cache search package-name

This searches available packages in your repositories. Replace 'package-name' with a partial or full name. This shows you what packages are available for installation.

If you already think the package might be installed, list all packages with a grep filter:

bash
dpkg -l | grep partial-name

This shows all packages that have been installed on your system with "partial-name" in their name.

2Update your package lists

Before installing, refresh your package database to ensure you have the latest package information:

bash
sudo apt update

This downloads the latest package lists from your configured repositories. Without this, apt might not know about recently added packages.

3Install the missing package

Once you've confirmed the correct package name, install it:

bash
sudo apt install package-name

Replace 'package-name' with the exact name from your apt-cache search results. After installation, dpkg-query will find it.

You can verify the installation succeeded:

bash
dpkg-query -l package-name

If successful, this displays the package details instead of the "no packages found" error.

4Properly quote wildcard patterns in scripts

If you're using dpkg-query with wildcards in a script, the shell may be interpreting the wildcards as filename patterns. Always quote the pattern:

bash
# WRONG - shell expands the wildcard before dpkg-query sees it
dpkg-query -l libc6*

# CORRECT - pass the literal pattern to dpkg-query
dpkg-query -l 'libc6*'

Single quotes prevent shell expansion, allowing dpkg-query to process the wildcard pattern correctly and match multiple packages.

5Check package status with dpkg directly

For more detailed status information about a specific package, use dpkg with the -s flag:

bash
dpkg -s package-name

If the package is installed, this shows its status, version, and metadata. If not installed, it returns an error with helpful information about why it can't be found.

This is useful in scripts when you need detailed information beyond just checking presence/absence.

Advanced notes

Exit Codes: dpkg-query returns specific exit codes. Exit code 1 indicates "The requested query failed either fully or partially, due to no file or package being found." Exit code 2 indicates fatal errors from invalid command-line usage or system interactions.

Database Location: The dpkg package database is located at /var/lib/dpkg by default. You can query a different database location using the --admindir option if working with a custom setup.

APT vs dpkg-query: Modern systems prefer using 'apt show package-name' over dpkg-query for users, as apt automatically refreshes the available package list. dpkg-query is best for checking what's installed, while apt is better for discovering what's available in repositories.

Exit Code Handling in Scripts: When writing shell scripts, check the exit code of dpkg-query. Use 'if dpkg-query -l package-name 2>/dev/null; then' to silently check if a package exists without displaying the error message.

Frequently asked questions

What does "dpkg-query: no packages found matching package-name" mean?
The dpkg-query tool is the database query interface for the Debian Package Manager (dpkg). When you run dpkg-query on a package name, it searches the local installed package database. If the package isn't in that database, dpkg-query reports that no packages match the search pattern.
How do I fix "dpkg-query: no packages found matching package-name"?
The "dpkg-query: no packages found matching" error occurs when you try to query or check a package that isn't installed on your Debian/Ubuntu system. This is typically a lookup error rather than a system failure.
What causes "dpkg-query: no packages found matching package-name"?
The package you're querying is not installed on the system The package name is misspelled or uses a different name than expected The actual package name differs from the program/tool name (e.g., the binary is 'python' but package is 'python3')
Is the "dpkg-query: no packages found matching package-name" error serious?
It is a low-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading