How to fix Required extension is not installed in PostgreSQL

PostgreSQLINTERMEDIATEHIGHUpdated Dec 28, 2025· 223 views

PostgreSQL extensions must have their supporting files installed on the system before you can use CREATE EXTENSION to load them into a database. This error occurs when the extension control file is missing or the extension package is not installed.

Quick fix

Fixes Required extension is not installed

SELECT * FROM pg_available_extensions WHERE name LIKE '%extension_name%';
  1. Check what extensions are available on your system
  2. Install the extension package on your system
  3. Create the extension in your database
  4. Handle extension dependencies
postgresql — error
SELECT * FROM pg_available_extensions WHERE name LIKE '%extension_name%';
Required extension is not installed

What this error means

PostgreSQL extensions are modular add-ons that provide additional functionality like UUID generation, JSON processing, or encryption. Before an extension can be loaded into a database with the CREATE EXTENSION command, PostgreSQL needs to find the extension's control file (usually located at `/usr/share/postgresql/VERSION/extension/extension_name.control`) and its supporting files on the system. When these files are missing, the database returns a "Required extension is not installed" error. This is different from an extension simply not being loaded in your database—it means the extension is not available on the PostgreSQL server itself, typically because the extension package was never installed on the operating system or system administrator path.

Typical symptoms

  • CREATE EXTENSION command fails with "is not installed" or "could not open extension control file"
  • Application startup fails when trying to initialize database extensions
  • Error message mentions "DETAIL: Could not open extension control file" with a path
  • Same error occurs across all databases on the server

Common causes

  1. Extension package was never installed on the system (e.g., postgresql-contrib not installed on Debian/Ubuntu)
  2. PostgreSQL version mismatch: extension exists for one version but not the currently running version
  3. Custom extension built but not installed to the correct system path
  4. Extension has unmet dependencies on other extensions that are not installed
  5. PostgreSQL installation is incomplete or missing the contrib modules

How to fix "Required extension is not installed"

1Check what extensions are available on your system

Connect to PostgreSQL and query the pg_available_extensions view to see which extensions the server can load:

sql
SELECT * FROM pg_available_extensions WHERE name LIKE '%extension_name%';

If your extension is not listed, it means the extension files are not installed on the system.

2Install the extension package on your system

For Debian/Ubuntu systems, install the postgresql-contrib package which contains common extensions:

bash
sudo apt-get update
sudo apt-get install postgresql-contrib

For other distributions:
- RedHat/CentOS/Fedora: sudo yum install postgresql-contrib
- Alpine: apk add postgresql-client
- macOS with Homebrew: brew install postgresql

After installation, restart PostgreSQL to ensure the new extensions are recognized.

3Create the extension in your database

Once the extension files are available on the system, you can load the extension into a specific database. Connect as a superuser and run:

sql
CREATE EXTENSION IF NOT EXISTS extension_name;

The IF NOT EXISTS clause prevents errors if the extension is already loaded. To load the extension into a specific schema:

sql
CREATE EXTENSION IF NOT EXISTS extension_name SCHEMA extensions_schema;
4Handle extension dependencies

Some extensions depend on other extensions being installed first. If you see a dependency error, use the CASCADE keyword to automatically install required dependencies:

sql
CREATE EXTENSION IF NOT EXISTS extension_name CASCADE;

You can check extension dependencies by querying:

sql
SELECT name, requires FROM pg_available_extensions WHERE name = 'extension_name';
5Verify the extension is loaded

After creating the extension, verify it's properly installed in your database:

sql
SELECT * FROM pg_extension WHERE extname = 'extension_name';

You can also list all extensions in the current database:

sql
\dx

The extension should now be available for use.

Advanced notes

For custom extensions you've built yourself, ensure the compiled shared library (.so file) and control file are installed to PostgreSQL's extension directory (typically /usr/lib/postgresql/VERSION/lib/ for the .so and /usr/share/postgresql/VERSION/extension/ for the control file and SQL files). Some extensions like TimescaleDB require preloading in postgresql.conf via the shared_preload_libraries parameter; check the extension documentation if you encounter a "must be preloaded" error. In containerized environments (Docker/Kubernetes), ensure the extension package is installed during the image build process, not at runtime.

Frequently asked questions

What does "Required extension is not installed" mean?
PostgreSQL extensions are modular add-ons that provide additional functionality like UUID generation, JSON processing, or encryption. control) and its supporting files on the system. When these files are missing, the database returns a "Required extension is not installed" error.
How do I fix "Required extension is not installed"?
PostgreSQL extensions must have their supporting files installed on the system before you can use CREATE EXTENSION to load them into a database. This error occurs when the extension control file is missing or the extension package is not installed.
What causes "Required extension is not installed"?
Extension package was never installed on the system (e.g., postgresql-contrib not installed on Debian/Ubuntu) PostgreSQL version mismatch: extension exists for one version but not the currently running version Custom extension built but not installed to the correct system path
Is the "Required extension is not installed" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading