Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Databases and Redis

CREATE EXTENSION postgis fails: could not open extension control file (Homebrew)

ErrorERROR: could not open extension control file

Short 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.

  • Applies to PostgreSQL 17, PostgreSQL 18, PostGIS 3.x, macOS Homebrew
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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%';
  2. 2Match what you see, then jump to its fix

    1. 1The 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. 2brew list postgis prints an error saying no such kegPostGIS is not installed at allFix
    3. 3Homebrew shows PostGIS installed, yet the running server's version or paths differThe server you are talking to is not the Homebrew oneFix

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 postgresql

2Fix

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 postgis

3Verify

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

Did this fix it?

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 postgis

2Fix

Install the package, then create the extension in each database that needs it.

brew install postgis

3Verify

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

Did this fix it?

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_config

2Fix

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_db

3Verify

The extension is available on the server you use.

SELECT name, default_version FROM pg_available_extensions WHERE name = 'postgis';

Confirmed by postgis.net

Did this fix it?

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

Next step

Want this handled for good?

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