I have recently installed PostgreSQL on my Mac via Homebrew. (I may have already had it installed; it was not running.)

brew install postgres
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents

Now I am trying to start it with launchctl:

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

...but I am getting an error:

/usr/local/Cellar/postgresql/9.4.0/homebrew.mxcl.postgresql.plist: Operation not permitted

What does this error mean? What am I doing wrong? How can I fix the problem?


2 Answers 2


It could be that you're using launchctl inside of Tmux or Screen.

Tmux and Screen are terminal multiplexers that spawn multiple "screens" that you can easily switch between in a single terminal.

For some reason unknown to me, running launchctl inside of Tmux never works, and emits the error Operation not permitted. Run it inside of a normal shell and it will probably work just fine.

  • Thanks! You are right, I was using tmux! However, I seem to be running into a different issue now. Using launchctl outside of tmux, I see "Operation already in progress", yet I cannot connect to Postgres.
    – Andrew
    Apr 7, 2015 at 19:03
  • I managed to solve my problem through some combination of unloading the launch agent plist, removing the old installation of Postgres, moving the old data directory, and reinstalling the latest version.
    – Andrew
    Apr 15, 2015 at 18:10
  • Finally i stumbled on this and answered why I have been struggling with for more than a month . Finally i know the reason thanks for this...
    – kenju254
    Jun 17, 2015 at 10:36
  • 2
    A solution for this is to use reattach-to-user-session as mentioned here: apple.stackexchange.com/questions/41412/… in your .tmux.conf Jun 17, 2015 at 12:36

Here are the steps you may need to take:

Remove a previous installation of PostgreSQL:

brew remove postgres
rm ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

Install the new version:

brew install postgres
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents

The data from your previous installation will need to be upgraded to be compatible with PostgreSQL 9.4+: http://www.postgresql.org/docs/9.4/static/upgrading.html

It seems like you need two installations of PostgreSQL in order to upgrade your database, and I didn't care to bother with that, so I just recreated the database with the new version:

mv /usr/local/var/postgres /usr/local/var/old-postgres
initdb -D /usr/local/var/postgres

Now launch PostgreSQL (outside of tmux if you are using that):

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

Check the logs for any issues:

tail /usr/local/var/postgres/server.log

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.