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.
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.
Connect to PostgreSQL and query the pg_available_extensions view to see which extensions the server can load:
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.
For Debian/Ubuntu systems, install the postgresql-contrib package which contains common extensions:
sudo apt-get update
sudo apt-get install postgresql-contribFor 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.
Once the extension files are available on the system, you can load the extension into a specific database. Connect as a superuser and run:
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:
CREATE EXTENSION IF NOT EXISTS extension_name SCHEMA extensions_schema;Some extensions depend on other extensions being installed first. If you see a dependency error, use the CASCADE keyword to automatically install required dependencies:
CREATE EXTENSION IF NOT EXISTS extension_name CASCADE;You can check extension dependencies by querying:
SELECT name, requires FROM pg_available_extensions WHERE name = 'extension_name';After creating the extension, verify it's properly installed in your database:
SELECT * FROM pg_extension WHERE extname = 'extension_name';You can also list all extensions in the current database:
\dxThe extension should now be available for use.
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.
insufficient columns in unique constraint for partition key
How to fix "insufficient columns in unique constraint for partition key" in PostgreSQL
ERROR 42501: must be owner of table
How to fix "must be owner of table" in PostgreSQL
trigger cannot change partition destination
How to fix "Trigger cannot change partition destination" in PostgreSQL
SSL error: certificate does not match host name
SSL error: certificate does not match host name in PostgreSQL
No SSL connection
No SSL connection to PostgreSQL