I'm upgrading to Postgres 9.2.2 (from 9.1.4). When I try to upgrade the DBs using:

pg_upgrade -b /usr/local/Cellar/postgresql/9.1.4/bin -B /usr/local/Cellar/postgresql/9.2.2/bin -d /usr/local/var/postgres91 -D /usr/local/var/postgres

I get the following error message:

Performing Consistency Checks
Checking current, bin, and data directories                 ok

There seems to be a postmaster servicing the old cluster.
Please shutdown that postmaster and try again.
Failure, exiting

I've trying stopping the server, but cannot get the upgrade command to work. How to I shutdown the old postmaster?

  • 1
    If you started the brew service then shut it down with brew services stop postgres
    – magnump0
    Nov 9, 2021 at 13:05

4 Answers 4


The postmaster.pid should be inside the previous version's usr/local/var folder. Simply renaming this file should solve the problem.

  • 1
    I've come across this problem a couple of times as well and this is a good answer. Stopping all instances of postgres before upgrading ought to be pertinent as well
    – Jerome
    Aug 8, 2014 at 15:32

In OS X Yosemite, after having installed PostgreSQL via Homebrew:

launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
  • 1
    This does not fix the problem. If pg_ctl -D /usr/local/var/postgres/ stop returns No such process, then you should rm /usr/local/var/postgres/postmaster.pid.
    – Andrew
    Jun 27, 2016 at 18:14
  • Also work after migrating from v.13 to v.14 on Big Sur
    – aUXcoder
    Oct 22, 2021 at 19:34

On Ubuntu, stop the PostgreSQL service before performing the upgrade. This will stop all instances of postgres regardless of the versions installed.

service postgresql stop

  • That was it. Forgot to stop postgres service before running brew postgresql-upgrade-database with brew services stop postgresql on my MacOS. Jan 2, 2023 at 23:20

On most unix systems you'll find a init script in /etc/init.d which you can use to start, restart, reload or stop unix services.


sudo /etc/init.d/postgresql stop

If this is not available you can use pg_ctl stop


su - postgres
bash-3.1$ pg_ctl stop  # normal stop
bash-3.1$ pg_ctl stop -m s # smart stop
bash-3.1$ pg_ctl stop -m f # fast stop
bash-3.1$ pg_ctl stop -m i # immediate stop

More about pg_ctl


EDIT If you still get the error and you are sure the postmaster is no longer running (check with sudo ps aux | grep "postmaster" - should return one line only) you still have the pid file after a unclean shutdown

Remove the pidfile e.g.

> sudo -u postgres mv /var/lib/postgres/data-9.1/postmaster.pid /tmp
  • 1
    When I try pg_ctl stop, I get: pg_ctl: no database directory specified and environment variable PGDATA unset. BTW, no server seems to be running: luciano$ ps auxwww | grep postgresluciano 995 0.0 0.0 2434892 548 s000 R+ 10:42PM 0:00.00 grep postgres.
    – Luciano
    Dec 18, 2012 at 0:42
  • grep for postmaster
    – Michel Feldheim
    Dec 18, 2012 at 7:46
  • Updated answer with further info
    – Michel Feldheim
    Dec 18, 2012 at 13:44
  • No luck: sudo ps aux | grep "postmaster" luciano 3101 0.0 0.0 2434892 548 s002 S+ 9:12PM 0:00.00 grep postmaster
    – Luciano
    Dec 18, 2012 at 23:23
  • Issue solved. See my answer.
    – Luciano
    Dec 19, 2012 at 0:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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