Diagnostic Queries
Symptoms
A command referenced an extension that is not available (its control/script files are not installed on the server). PostgreSQL raises SQLSTATE 42704 (undefined_object).
- The named extension isn’t available to install.
- Common when the extension package isn’t on the server.
- Distinct from “already exists”.
What the server log shows
ERROR: extension "postgis" is not available
DETAIL: Could not open extension control file "/usr/share/postgresql/extension/postgis.control": No such file or directory.
HINT: The extension must first be installed on the system where PostgreSQL is running.
Why PostgreSQL raises this — what the manual says
the CREATE EXTENSION reference (Notes):
“Before you can use CREATE EXTENSION to load an extension into a database, the extension’s supporting files must be installed.”
CREATE EXTENSION loads from on-disk control/script files. If those files aren’t installed at the OS level, the extension can’t be resolved, so PostgreSQL reports 42704.
Common causes
- The extension’s OS package isn’t installed on the server.
- A typo in the extension name.
- The extension files are in a different PostgreSQL installation.
How to fix it
- Install the extension package on the server (e.g.
postgresql-contribor the vendor package). - List available extensions:
SELECT * FROM pg_available_extensions;. - Then run
CREATE EXTENSION postgis;.
Related & next steps
Reference: PostgreSQL 18 — CREATE EXTENSION.
Thanks — noted. This helps keep the database accurate.