SQLSTATE 42704 ERROR Class 42: Syntax Error or Access Rule Violation

undefined_object extension “…” is not available — 42704

PostgreSQL error “extension … is not available — 42704” (SQLSTATE 42704): what it means, common causes, and how to fix it.

PG 9.6, 10, 11, 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed Jun 2026 Grounded in source

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

  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.

Was this helpful?