extension “…” already exists

SQLSTATE 42710 condition duplicate_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 CREATE EXTENSION named an extension that is already installed in the database. PostgreSQL raises SQLSTATE 42710 (duplicate_object).

What the server log shows

ERROR:  extension "pgcrypto" already exists

Why PostgreSQL raises this — what the manual says

the CREATE EXTENSION reference (Description):

“There must not be an extension of the same name already loaded.”

Each extension can be installed once per database (tracked in pg_extension). Re-creating one that already exists collides with the installed object, so PostgreSQL reports 42710.

Common causes

How to fix it

  1. Use CREATE EXTENSION IF NOT EXISTS pgcrypto; for idempotency.
  2. Check existing extensions: SELECT extname FROM pg_extension;.
  3. To upgrade, use ALTER EXTENSION … UPDATE instead of re-creating.

Related & next steps

Reference: PostgreSQL 18 — CREATE EXTENSION.