PostgreSQL server wouldn't shutdown on Lion (Mac OS 10.7)

MacosPostgresqlOsx Lion

Macos Problem Overview


I installed PostgreSQL using Homebrew on Lion. It starts okay but wouldn't shutdown. I tried:

$ #started with
$ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
$ #tried stoping with
$ pg_ctl -D /usr/local/var/postgres stop -m immediate
waiting for server to shut down................................... failed
pg_ctl: server does not shut down

I fixed this issue by deleting the Launch Agent:

launchctl unload -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
rm ~/Library/LaunchAgents/org.postgresql.postgres.plist

Macos Solutions


Solution 1 - Macos

launchctl unload -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
rm ~/Library/LaunchAgents/org.postgresql.postgres.plist

Solution 2 - Macos

Shutting down PostgreSQL Server with -m immediate is a dangerous way to do it, because “Immediate” mode will abort all server processes without a clean shutdown.

This will lead to a recovery run on restart. Try to shutdown PostgreSQL with parameter -m fast instead. "Fast” mode does not wait for clients to disconnect and will terminate an online backup in progress. All active transactions are rolled back and clients are forcibly disconnected

pg_ctl stop -D /usr/local/var/postgres -m fast 

For more information about pg_ctl please visit http://www.postgresql.org/docs/9.0/static/app-pg-ctl.html

Solution 3 - Macos

This works for me

  pg_ctl -D /Library/PostgreSQL/9.2/data/ start
  pg_ctl -D /Library/PostgreSQL/9.2/data/ stop

Source https://sites.google.com/site/amaosblog/database/postgresql/how-to-start-stop-postgresql-9-2-on-mac-os-x-10-8-x

Solution 4 - Macos

If you used Homebrew to install postgresql, then as Shevauns comment on Greg's answer indicates, the correct procedure is

launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionGregView Question on Stackoverflow
Solution 1 - MacosGregView Answer on Stackoverflow
Solution 2 - MacosfrancsView Answer on Stackoverflow
Solution 3 - MacosSathishVenkatView Answer on Stackoverflow
Solution 4 - MacosObromiosView Answer on Stackoverflow