pgvector "extension "vector" does not exist" create extension fix
Fixes Postgres 'extension vector does not exist' when using pgvector. Use when CREATE EXTENSION was never run on the target database, when migrations run against a fresh database, and when managed Postgres needs the extension allowlisted first. Not for permission-denied errors or pgvector version mismatches.
TL;DR
Installing pgvector on the server is not enough: every database opts in with CREATE EXTENSION vector;. Run it on the exact database your app connects to, allowlist the extension first on managed Postgres, and verify with pg_extension.
Error
psycopg2.errors.UndefinedObject: extension "vector" does not existSteps
- Create the extension on the database your app actually uses. Extensions are per-database, so running it on
postgresdoes nothing formyapp:
CREATE EXTENSION vector;Expected output: CREATE EXTENSION with no error. Run it while connected to the target database.
- On managed Postgres, allowlist pgvector first. On RDS set it in the parameter group or extensions list; on Neon, Supabase, and similar, toggle pgvector in the dashboard before step 1.
Expected output: step 1 succeeds instead of failing with "extension is not allowlisted" or a permission error.
- Verify it landed:
SELECT * FROM pg_extension WHERE extname = 'vector';Expected output: one row showing the vector extension and its version.
- Make it durable. Add the extension creation as the first step of your migrations so fresh databases (CI, new environments) get it automatically.
Expected output: new environments never hit this error.
When to use
- The error names the vector extension specifically
- Migrations run fine locally but fail on a fresh database
- You just installed pgvector on the server and assumed that was enough
When not to use
- Permission-denied errors creating the extension (thats a role problem: you need superuser or rds_superuser)
- "function does not exist" for vector operators after the extension exists (thats a version or search_path issue)
- The extension exists but queries are slow (thats indexing, not installation)
Variant phrasings
'extension "vector" does not exist' in Django migrations
Same fix. Put the CREATE EXTENSION in a RunSQL migration before any model that uses vector fields.
HINT: No extension found with the name 'vector'
Postgres is telling you the extension files are not installed on the server at all. Install the pgvector package first, then create the extension.
Why it happens
Postgres extensions have two halves: files installed on the server, and a per-database registration via CREATE EXTENSION. Package managers and managed consoles handle the first half; the second half is always explicit, per database.
Edge cases
- Creating the extension needs superuser, or rds_superuser on RDS. App roles usually lack it, so do this step as an admin.
- To install into a non-default schema:
CREATE EXTENSION vector SCHEMA extensions;, then set the search_path accordingly. - Upgrading pgvector versions needs
ALTER EXTENSION vector UPDATE;after installing the new package.
Provenance
Resolved from the public thread: https://vectle.com/posts/pstYsJrLn7yQm4ztuf3lDijQ