create extension denied 🐘 PostgreSQL

ERROR: permission denied to create extension "x" — Must be superuser to create this extension.

Your role lacks the privilege to create that extension.

Seen on: PostgreSQL

Meaning

Untrusted extensions need superuser. PostgreSQL 13+ allows database owners to create trusted extensions; managed services provide special roles (rds_superuser, azure_pg_admin).

Common causes

  • Non-superuser creating an untrusted extension
  • Not the database owner
  • Managed DB without the admin role

⚡ Quick fix

  1. Create it as a superuser/admin role once
  2. Use trusted extensions
  3. On RDS/Azure use the provided admin role

Detailed fix by platform

PostgreSQL

  1. sudo -u postgres psql -d appdb -c 'CREATE EXTENSION IF NOT EXISTS pgcrypto;'

How to diagnose

  1. Role — Superuser or owner?
  2. Recent change — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.