extension “…” is not available

SQLSTATE 42704 condition undefined_object class 42 — Syntax Error or Access Rule Violation severity ERROR
Reproduced & verified on PostgreSQL 14.23, 15.18, 16.14, 17.10 and 18.4 — identical message on every version.
Last reviewed 11 Jun 2026 · Reproduced live with the SQL on this page.

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).

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

How to fix it

  1. Install the extension package on the server (e.g. postgresql-contrib or the vendor package).
  2. List available extensions: SELECT * FROM pg_available_extensions;.
  3. Then run CREATE EXTENSION postgis;.

Related & next steps

Reference: PostgreSQL 18 — CREATE EXTENSION.