CREATE EXTENSION postgis fails: could not open extension control file (Homebrew)
ERROR: could not open extension control fileShort answer
The server looked for postgis.control in its own extension folder and found nothing. On Homebrew that means PostGIS was not installed for the PostgreSQL version that is running, or the running server is not the Homebrew one you installed PostGIS against. Match the two, then run CREATE EXTENSION again.
Fix it fast
1Find out which cause you have
Ask the running server which extensions it can load and which version it is.
SELECT version(); SELECT name, default_version FROM pg_available_extensions WHERE name LIKE 'postgis%';2Match what you see, then jump to its fix
- 1
The path in the error contains an older server such as postgresql@13, and the query above returns no postgis rowPostGIS is not built for your PostgreSQL versionFix - 2
brew list postgis prints an error saying no such kegPostGIS is not installed at allFix - 3
Homebrew shows PostGIS installed, yet the running server's version or paths differThe server you are talking to is not the Homebrew oneFix
- 1
What does the error look like?
ERROR: could not open extension control file/opt/homebrew/opt/postgresql@13/share/postgresql@13/extension/postgis.control
Cause 1 of 3
PostGIS is not built for your PostgreSQL version
1Check
Homebrew's postgis formula lists postgresql@17 and postgresql@18 as the servers it builds against. An older Homebrew server has no matching extension files.
brew info postgis
brew list --versions | grep postgresql2Fix
Move the server to a version the PostGIS formula supports (dump and restore your data first), then reinstall PostGIS.
brew install postgresql@17
brew install postgis3Verify
Start the new server and check that postgis is now listed as available.
psql -d postgres -c "SELECT name FROM pg_available_extensions WHERE name = 'postgis';"Confirmed by formulae.brew.sh
Cause 2 of 3
PostGIS is not installed at all
1Check
CREATE EXTENSION can only load an extension whose files are already installed on the server machine.
brew list postgis2Fix
Install the package, then create the extension in each database that needs it.
brew install postgis3Verify
Create the extension and print its version.
psql -d my_db -c "CREATE EXTENSION IF NOT EXISTS postgis;"
psql -d my_db -c "SELECT postgis_version();"Confirmed by postgresql.org
Cause 3 of 3
The server you are talking to is not the Homebrew one
1Check
PostgreSQL extension files live in the directories pg_config reports for the installation they were built for. Another server on the same port (Postgres.app, a package installer, Docker) has its own folder.
psql -d postgres -c "SHOW data_directory;"
pg_config --sharedir
which -a pg_config2Fix
Connect to the server PostGIS was installed for, or install PostGIS for the server you actually use. Do not copy files between installations by hand.
psql -p 5433 -d my_db3Verify
The extension is available on the server you use.
SELECT name, default_version FROM pg_available_extensions WHERE name = 'postgis';Confirmed by postgis.net
How do I stop it coming back?
- Pin one PostgreSQL major version in Homebrew and check postgis supports it before upgrading either.
- Run only one PostgreSQL server per port on a development machine.
- Create the extension in a migration, so a missing install fails early.
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
Databases
PostGIS is installed, but type "geometry" does not exist
CREATE TABLE places (geom geometry(Point, 4326)); fails
Installing the PostGIS package does not make it usable.
3 causes, each with a fixDatabases
DBeaver cannot run pg_restore: the utility is not found in the client home
Utility 'pg_restore' not found in client home '/usr/lib' (/usr/lib)
DBeaver runs pg_restore from a local PostgreSQL client folder; it does not bundle one.
3 causes, each with a fixDatabases
DBeaver cannot download the PostgreSQL driver from Maven
The PostgreSQL driver files are missing and the download does not complete
DBeaver downloads the PostgreSQL JDBC driver from a Maven repository the first time you connect.
3 causes, each with a fixDatabases
python manage.py migrate finishes but the tables for my app are missing
relation "myapp_book" does not exist
migrate only applies migration files that exist.
3 causes, each with a fixDatabases
Django save fails on PostgreSQL: null value in a column violates a not-null constraint
django.db.utils.IntegrityError: null value in column "price" of relation "shop_product" violates not-null constraint
A model field is NOT NULL in the database unless it has null=True.
3 causes, each with a fixDatabases
Django migration on PostgreSQL stops with 'pending trigger events'
django.db.utils.OperationalError: cannot ALTER TABLE "mytable" because it has pending trigger events
PostgreSQL runs a Django migration in one transaction.
2 causes, each with a fix