Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Databases and Redis

Postgres cannot find the vector type for pgvector

ErrorERROR: type "vector" does not exist

Short answer

Installing pgvector on the server is not enough. The extension must also be created inside every database that uses it, with CREATE EXTENSION vector. If that statement fails, the extension files are not installed on that server. If it succeeded but the type is still missing, it went into a schema that is not on your search_path.

  • Applies to PostgreSQL 16 and later, pgvector 0.8, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Connect to the exact database your app uses and list what is installed there and what the server could install. This separates a missing server install from a missing per-database step.

    psql "$DATABASE_URL" -c "SELECT extname, extversion FROM pg_extension WHERE extname = 'vector';" \
         -c "SELECT name, default_version FROM pg_available_extensions WHERE name = 'vector';"
  2. 2Match what you see, then jump to its fix

    1. 1The first query returns no rows and the second returns one row.The extension was never created in this databaseFix
    2. 2Both queries return no rows, or CREATE EXTENSION itself fails.pgvector is not installed on the PostgreSQL serverFix
    3. 3pg_extension shows vector, but the type still cannot be found by an unqualified name.The extension went into a schema that is not on the search_pathFix

What does the error look like?

  • ERROR: type "vector" does not exist

Cause 1 of 3

The extension was never created in this database

1Check

pgvector's README says to run CREATE EXTENSION once in each database that uses it. A new database, a restored dump or a test database starts without it.

psql "$DATABASE_URL" -c "SELECT current_database();"

2Fix

Run it in that database, and run it again for every other one (for example a test database).

psql "$DATABASE_URL" -c "CREATE EXTENSION IF NOT EXISTS vector;"

3Verify

The extension now shows up with a version.

psql "$DATABASE_URL" -c "SELECT extversion FROM pg_extension WHERE extname = 'vector';"

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 2 of 3

pgvector is not installed on the PostgreSQL server

1Check

PostgreSQL can create an extension only when its control file is installed on the server; pg_available_extensions lists what it can see.

psql "$DATABASE_URL" -c "SELECT name FROM pg_available_extensions WHERE name = 'vector';"

2Fix

Install pgvector for your PostgreSQL major version, on the machine running the server. On Debian or Ubuntu that is the apt package named after your version (replace 17 with yours; the Docker tag likewise names a version); in Docker, use the image that already includes it.

sudo apt install postgresql-17-pgvector
# or in Docker (replace 18 with your version)
docker pull pgvector/pgvector:pg18-trixie

3Verify

pg_available_extensions now lists vector; then run CREATE EXTENSION.

psql "$DATABASE_URL" -c "SELECT name FROM pg_available_extensions WHERE name = 'vector';"

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 3 of 3

The extension went into a schema that is not on the search_path

1Check

An extension's objects are created in one schema (the default creation schema unless SCHEMA is given), and only schemas on search_path resolve unqualified names.

psql "$DATABASE_URL" -c "SHOW search_path;"

2Fix

Reference the type with the schema it was created in, or create the extension where your tables live with CREATE EXTENSION vector SCHEMA your_schema (the schema must already exist).

-- if the extension lives in a schema called extensions
CREATE TABLE items (embedding extensions.vector(3));

3Verify

The table creation succeeds without a type error.

psql "$DATABASE_URL" -c "CREATE TEMP TABLE t (v extensions.vector(3));"

Confirmed by postgresql.org

Did this fix it?

How do I stop it coming back?

  • Put CREATE EXTENSION IF NOT EXISTS vector in your first migration so every new database gets it.
  • Run the same migration against the test database.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.