From what I could determine, this is likely due to a versioning error between postgres and postgis. It seems that brew install postgis
will install the most recent version of postgres and make the postgis extension available only to that version. I got it to work by uninstalling previous versions of postgres and doing a clean install of the most recent version (the one the postgis is expecting). You can find the version postgis is expecting by searching the homebrew site.
First, back up your database if you need to save your data. (See pgdump.)
Next, stop all of the running postgres server instances. Try the following:
- Use
brew services list
to see all postgres services running. Use brew services stop [name]
to stop any listed postgres services that are running.
- Use
sudo lsof -i :5432
to confirm that no database server is listening on port 5432. (This is the default port for postgres.) If you see any results, use sudo kill [pid]
to stop the server.
Now, uninstall postgres:
brew uninstall --force postgresql
Then delete the database file (this removes your data so make a backup):
rm -rf /usr/local/var/postgres
Now you can follow these setup instructions to install postgres. Note that the default superuser of your database will be the one you use to do the initdb
command. Thus, you may want to use sudo -u postgres
before doing the initdb
to keep the default database superuser name "postgres". (See more about default users here.)