I am trying to re-install Postgres via home-brew on Mac. I uninstalled Postgres, updated home-brew and ran the install command for brew install postgres

when I run brew services start postgresql

I get the below error message:

Bootstrap failed: 5: Input/output error Error: Failure while executing; /bin/launchctl bootstrap gui/501 /Users/edac/Library/LaunchAgents/homebrew.mxcl.postgresql.plist exited with 5.

When I try to start a server through the Postgres app I receive this message:

Required PostgreSQL version not installed

The data directory was initialized with PostgreSQL 13.

This copy of Postgres.app includes the following PostgreSQL versions: 14.

Please try downloading a different release of Postgres.app.

originally when I installed Postgres all I did was run the home-brew cli and install the app and I was good to go. Not sure what's gone wrong.


7 Answers 7


The issue is the previous install of postgres was postgres 13, and it created a database under:


which is now incompatible with the version of postgres you're installing, which is version 14.

First question: Do you care about your data?

If not then you can simply delete that folder and attempt to restart the service.

to delete and restart the service do:

rm -rf /usr/local/var/postgres
initdb --locale=C -E UTF8 /usr/local/var/postgres
brew services start postgresql

Otherwise you need to install postgresql@13, and perform a database migration, which can be summed up as follows:

install older postgres, make sure it's stopped

brew install postgresql@13
brew services stop postgresql@13
brew services stop postgres

delete the postgres 13 database created by the installation of postgresql@13

rm -rf /usr/local/var/postgresql@13

move old data to compatible driver folder:

mv /usr/local/var/postgres /usr/local/var/postgresql@13

Now we do the upgrade. First cd to the database folder

cd /usr/local/var

Construct a new blank database, with locale C, encoding of UTF8

initdb --locale=C -E UTF8 -D postgres

Perform the upgrade itself:

pg_upgrade -d postgresql@13 -D postgres -b /usr/local/Cellar/postgresql@13/13.4/bin -B /usr/local/Cellar/postgresql/14.0/bin -v

This should end in success. If it doesn't (e.g. locale/encoding is wrong), then chose the locale and encoding that matches the database.

Finally restart the postgres service:

brew services start postgresql
  • 1
    For newer versions of homebrew, you will need to look at /opt/homebrew/var/postgres rather than /usr/local/var/postgres
    – ZX9
    Commented Apr 27, 2023 at 17:05
  • 1
    That's on silicon macs, where it has been decided to install native binaries in /opt/homebrew, but to still leave non-native binaries (running under rosetta2) in /usr/local Commented May 10, 2023 at 17:36

The problem is really what @Petesh said. But, the resolution for me was simpler.

When you upgrade your postgresql with brew, it logs a success message. One thing registered will be:

To migrate existing data from a previous major version of PostgreSQL run:
  brew postgresql-upgrade-database

So the only thing you need to do is to run the command below:

brew postgresql-upgrade-database

And of course you need to restart the service:

brew services restart postgresql

If you want to make sure it worked, you can run the start command too:

brew services start postgresql
  • cool - I didn't realize that there was a brew helper for this Commented Nov 2, 2021 at 21:33
  • I had to run the command twice but this is the one which fixed it.
    – Hal
    Commented Dec 1, 2021 at 6:35

I faced a similar problem with postgresql 11 and restarting the service did not help. The issue arose when my MacBook restarted abruptly.

After checking the ports and trying out all the possible solutions, I decided to look into the logs.

tail -n 100 /usr/local/var/log/[email protected]

This gave me the last 100 lines of the log where I found this:

FATAL:  lock file "postmaster.pid" already exists
HINT:  Is another postmaster (PID 479) running in data directory "/usr/local/var/postgresql@11"?

Clearly, the issue was with postmaster.pid so I deleted it:

rm /usr/local/var/postgresql@11/postmaster.pid

Started the postgres service again:

brew services start postgresql@11

and voila! It worked.

  • 2
    This also worked for me. Had the same problem, postgres wasn't working after my MacBook shut down abruptly. My pid file location was /opt/homebrew/var/postgres/postmaster.pid Commented Jun 9, 2022 at 8:11

It seems that the postgresql is already started before running the start command.

So do restart it instead of starting, by the following command:

brew services restart postgresql

I had this for Apache. To fix it, I unloaded the plist file. In your case

launchctl unload /Users/edac/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
launchctl load /Users/edac/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

Then I re-ran the start services command and it worked.

brew services start postgresql
  • This worked for me. The problem I was having was that it kept wanting to run as the root user. /usr/local/var/log/postgres.log said "root" execution of the PostgreSQL server is not permitted. The server must be started under an unprivileged user ID to prevent possible system security compromise. See the documentation for more information on how to properly start the server. Doing these steps let "brew services start postgresql" work by running as me instead of root for some reason.
    – Marty
    Commented Dec 1, 2021 at 21:17

I cannot tell you why but the only solution that solved the issue for me was to uninstall and install postgresql completely. (it stopped working after a reboot on my M1 mac running macOS 12.6 Monterey)

brew uninstall postgresql@14
brew install postgresql@14

check if it worked (status shall say 'started' by now)

brew services list


Happened suddenly but following step fixed the restart issue:

rm /usr/local/var/postgresql@11/postmaster.pid worked for me because instance was already running.

brew services start postgresql@14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .