How to fix Extension does not exist in PostgreSQL

PostgreSQLINTERMEDIATEHIGHUpdated Dec 28, 2025ยท 189 views

This error occurs when PostgreSQL cannot find a required extension. The extension files may not be installed, or they are not available in the system. Most commonly, you need to install the extension using CREATE EXTENSION or ensure the required packages are installed on your system.

Quick fix

Fixes Extension does not exist

SELECT * FROM pg_available_extensions WHERE name = 'pg_trgm';
  1. Check if the extension is available on your system
  2. Install the PostgreSQL contrib package (Linux)
  3. Create the extension as a superuser
  4. For managed database services
postgresql โ€” error
SELECT * FROM pg_available_extensions WHERE name = 'pg_trgm';
Extension does not exist

What this error means

PostgreSQL extensions are optional packages that add functionality like full-text search (pg_trgm), UUID generation (uuid-ossp), or JSON processing (json). When PostgreSQL attempts to load or use an extension that is not installed on the system, it raises this error. This typically happens when: (1) the extension has never been installed on the server, (2) the system package containing the extension is missing, or (3) the extension files are not in the expected location. PostgreSQL stores available extensions in the pg_available_extensions system view, and the extension control files are usually located in the SHAREDIR/extension directory.

Typical symptoms

  • SQL queries fail with "ERROR: extension does not exist"
  • CREATE EXTENSION command returns an error for the specific extension
  • Application startup fails when trying to initialize database with missing extensions
  • Database migration or initialization scripts fail during setup
  • Functions or data types from the extension are not found

Common causes

  1. Extension supporting files are not installed on the PostgreSQL server
  2. PostgreSQL contrib package is not installed (common on Linux systems)
  3. Extension is not available for the installed PostgreSQL version
  4. PostgreSQL was installed but optional packages/extensions were skipped during installation
  5. Using a managed database service (AWS RDS, Google Cloud SQL, Heroku) that does not support the extension

How to fix "Extension does not exist"

1Check if the extension is available on your system

Connect to PostgreSQL and query the available extensions:

sql
SELECT * FROM pg_available_extensions WHERE name = 'pg_trgm';

If this returns no results, the extension is not available and you need to install the supporting files.

2Install the PostgreSQL contrib package (Linux)

On most Linux systems, extensions come in a separate package. Install it:

Ubuntu/Debian:

bash
sudo apt-get install postgresql-contrib

CentOS/RHEL:

bash
sudo yum install postgresql-contrib

Fedora:

bash
sudo dnf install postgresql-contrib

After installation, restart PostgreSQL or reconnect to see the extensions.

3Create the extension as a superuser

Once the extension files are installed, create the extension in your database. Connect as a superuser (usually postgres):

bash
psql -U postgres -d your_database

Then create the extension:

sql
CREATE EXTENSION IF NOT EXISTS pg_trgm;

Use IF NOT EXISTS to avoid errors if the extension is already installed. Check that it was created:

sql
\dx
4For managed database services

If using AWS RDS, Google Cloud SQL, Azure Database, or similar:

1. Check if the extension is in the allowed list for your service
2. Some providers require enabling extensions via parameter groups or settings
3. Not all extensions are supported by managed services
4. If your required extension is unsupported, you may need to use a self-hosted PostgreSQL instance or choose an alternative extension

For example, AWS RDS allows you to create extensions directly if they are supported, but some extensions require additional setup or are not available at all.

5Verify the extension is installed

After creating the extension, verify it is available:

sql
\dx

This lists all installed extensions. You should see your extension (e.g., pg_trgm) listed.

You can now use the extension's functions and data types:

sql
CREATE INDEX idx_gin_text ON my_table USING gin(column_name gin_trgm_ops);

Advanced notes

Schema considerations: Extensions can be created in specific schemas. By default, they install into the public schema, but you can specify a schema using CREATE EXTENSION ... SCHEMA schema_name; if needed. Some extensions like timescaledb require additional PostgreSQL configuration (shared_preload_libraries) and must be set at server startup. If the extension appears installed (visible in pg_extension) but functions are not found, check your search_path setting with SHOW search_path; and ensure the extension's schema is included. For security-sensitive deployments, only trusted extensions should be installed.

Frequently asked questions

What does "Extension does not exist" mean?
PostgreSQL extensions are optional packages that add functionality like full-text search (pg_trgm), UUID generation (uuid-ossp), or JSON processing (json). When PostgreSQL attempts to load or use an extension that is not installed on the system, it raises this error. This typically happens when: (1) the extension has never been installed on the server, (2) the system package containing the extension is missing, or (3) the extension files are not in the expected location.
How do I fix "Extension does not exist"?
This error occurs when PostgreSQL cannot find a required extension. The extension files may not be installed, or they are not available in the system. Most commonly, you need to install the extension using CREATE EXTENSION or ensure the required packages are installed on your system.
What causes "Extension does not exist"?
Extension supporting files are not installed on the PostgreSQL server PostgreSQL contrib package is not installed (common on Linux systems) Extension is not available for the installed PostgreSQL version
Is the "Extension does not exist" 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