How to fix Could not open extension control file in PostgreSQL

PostgreSQLBEGINNERHIGHUpdated Dec 28, 2025· 333 views

PostgreSQL cannot locate the required .control file for an extension. This happens when extension packages are missing or not properly installed on your system.

Quick fix

Fixes Could not open extension control file

pg_config --sharedir
  1. Verify the PostgreSQL share directory location
  2. Install postgresql-contrib package
  3. Install extension-specific packages if needed
  4. Verify the control file exists
postgresql — error
pg_config --sharedir
Could not open extension control file

What this error means

This error occurs when you attempt to create a PostgreSQL extension using CREATE EXTENSION, but PostgreSQL cannot find the extension's control file (.control) in the expected system directory. The control file is a metadata file that PostgreSQL uses to understand how to install and configure an extension. Without it, the extension cannot be loaded into the database.

Typical symptoms

  • CREATE EXTENSION command fails with "could not open extension control file" error
  • Error message includes the full path like "/usr/share/postgresql/13/extension/[extension].control"
  • Specific extensions like PostGIS, pgvector, or contrib extensions cannot be created
  • Error appears as "No such file or directory" when trying to install extensions

Common causes

  1. The postgresql-contrib package or extension-specific package is not installed on the system
  2. Extension files were not included during the initial PostgreSQL installation
  3. Extension package version is incompatible with the installed PostgreSQL version
  4. The extension package was removed or uninstalled after PostgreSQL was set up
  5. On Windows, the Application Stack Builder was not used to install optional extensions
  6. File permissions prevent PostgreSQL from reading the extension directory

How to fix "Could not open extension control file"

1Verify the PostgreSQL share directory location

First, determine where PostgreSQL expects to find extension files:

bash
pg_config --sharedir

This command returns the path where PostgreSQL looks for extension control files (typically /usr/share/postgresql/13 or /usr/pgsql-13/share).

2Install postgresql-contrib package

Most missing extensions are provided by the postgresql-contrib package. Install it for your PostgreSQL version:

On Ubuntu/Debian:

bash
sudo apt install postgresql-contrib

On RHEL/CentOS:

bash
sudo yum install postgresql-contrib

On macOS:

bash
brew install postgresql

Make sure to match your PostgreSQL version number if needed (e.g., postgresql-13-contrib).

3Install extension-specific packages if needed

Some extensions require separate packages beyond contrib:

For PostGIS on Ubuntu:

bash
sudo apt install postgresql-[VERSION]-postgis postgresql-[VERSION]-postgis-scripts

For pgvector:

bash
# pgvector usually requires compilation or pre-built packages
# Check your package manager or build from source

Replace [VERSION] with your PostgreSQL version number (13, 14, 15, etc.).

4Verify the control file exists

After installation, check if the .control file is now present:

bash
find /usr/share/postgresql -name "*.control" | grep [extension_name]

For example, to find PostGIS:

bash
find /usr/share/postgresql -name "postgis.control"

If the file is found, the extension package was installed successfully.

5Create the extension in PostgreSQL

Once the extension package is installed, create the extension in your database:

sql
CREATE EXTENSION [extension_name];

For example:

sql
CREATE EXTENSION postgis;
CREATE EXTENSION pg_trgm;
CREATE EXTENSION vector;

Note: For pgvector, use vector as the extension name, not pgvector.

6Check file permissions if needed

If the .control file exists but PostgreSQL still cannot access it, verify permissions:

bash
ls -l /usr/share/postgresql/[version]/extension/ | head

The directory and files should be readable by the PostgreSQL system user. If permissions are incorrect:

bash
sudo chmod 644 /usr/share/postgresql/[version]/extension/*.control
sudo chmod 755 /usr/share/postgresql/[version]/extension/

Advanced notes

For custom PostgreSQL installations to non-standard locations, you may need to set the extension_control_path configuration parameter in postgresql.conf. Custom installations typically place extensions in paths like /usr/local/postgresql/share or /opt/postgresql/share. On Windows, the PostgreSQL Application Stack Builder (stackbuilder.exe) automatically installs optional extensions to the correct location—use this tool rather than manual installation for best results. Version mismatches are a common cause: ensure your extension version matches your PostgreSQL major version. Some older extension packages may not be available for newer PostgreSQL versions.

Frequently asked questions

What does "Could not open extension control file" mean?
control) in the expected system directory. The control file is a metadata file that PostgreSQL uses to understand how to install and configure an extension. Without it, the extension cannot be loaded into the database.
How do I fix "Could not open extension control file"?
PostgreSQL cannot locate the required .control file for an extension. This happens when extension packages are missing or not properly installed on your system.
What causes "Could not open extension control file"?
The postgresql-contrib package or extension-specific package is not installed on the system Extension files were not included during the initial PostgreSQL installation Extension package version is incompatible with the installed PostgreSQL version
Is the "Could not open extension control file" 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