How to fix Required extension is not installed in PostgreSQL
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%';- Check what extensions are available on your system
- Install the extension package on your system
- Create the extension in your database
- Handle extension dependencies
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
- 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
- Extension has unmet dependencies on other extensions that are not installed
- PostgreSQL installation is incomplete or missing the contrib modules
How to fix "Required extension is not installed"
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.
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
- 📚PostgreSQL Official Documentation
- 📖PostgreSQL CREATE EXTENSION Documentation(Official Docs)
- 📖PostgreSQL Extension Packaging Guide(Official Docs)
- 📚