26

Ive actually had this problem for a while but I've finally decided to take it on. Postgres was initially installed using Brew.

After my upgrade to OSX 10.8.2 to receive a

psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

error when I typed the

$ psql

command.

I see the following processes:

$ ps auxw | grep post
Tulsa           59222   0.0  0.2  2483256  14808   ??  Ss   Thu03PM   0:02.61 /System/Library/PrivateFrameworks/DiskImages.framework/Resources/diskimages-helper -uuid 470DA5CC-1602-4D69-855F-F365A6512F90 -post-exec 4
Tulsa           57940   0.0  0.2  2498852  13648   ??  Ss   Wed10PM   0:00.61 /System/Library/PrivateFrameworks/DiskImages.framework/Resources/diskimages-helper -uuid FAFAAAB4-0F67-42C8-864E-EF8C31A42EE3 -post-exec 4
root            24447   0.0  0.1  2476468  10080   ??  Ss    8Feb13   0:03.40 /System/Library/PrivateFrameworks/DiskImages.framework/Resources/diskimages-helper -uuid CC768720-12C2-436C-9020-548C275A6B0C -post-exec 4
Tulsa           74224   0.0  0.0  2432768    596 s002  R+    7:24PM   0:00.00 grep post


$ which psql
/usr/local/bin/psql

$ pg_ctl start 
pg_ctl: no database directory specified and environment variable PGDATA unset
Try "pg_ctl --help" for more information. 
Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697
harristrader
  • 1,181
  • 2
  • 13
  • 20
  • 31
    I have no clue what this is all about, but the title is priceless... +1 – Mathieu Guindon Feb 19 '13 at 01:40
  • 4
    @retailcoder: It seems like it *should* be "Upgrading OS/X is ruining my life." – Mike Sherrill 'Cat Recall' Feb 19 '13 at 01:55
  • 2
    I'm pretty sure `-post-exec` has *nothing* to do with PostgreSQL. So the server isn't running locally. On Linux, its processes can be found with `ps aux | grep postgres`. I'd be a little surprised if that were different on OS/X. Do what pg_ctl tells you. – Mike Sherrill 'Cat Recall' Feb 19 '13 at 02:00
  • as the error said, `PGDATA is unset`. Try the solution I has given here and see if it works for you: http://stackoverflow.com/questions/14949053/ps-auxwww-grep-psql-postgres-not-running-with-homebrew. Good luck! :D – kasperite Feb 19 '13 at 03:28
  • 1
    No, MacOS X is ruining your life. See http://harmful.cat-v.org/software/operating-systems/osx/osx-unsuitable-web-development – sayap Feb 19 '13 at 04:48
  • How did you install PostgreSQL in the first place? via Homebrew maybe? If so, it seems likely that the server autostart in the postgresql package for homebrew has been broken by your OS X update. Look at your launchd configuration, Console logs, and your PostgreSQL log files for more information. "Mac OS X's insane update process is ruining my life..." – Craig Ringer Feb 19 '13 at 06:58

1 Answers1

35

You haven't started the Postgres server. Some of the dmg packages for Postgres set it to run as a service on startup. But not however you did the install.

You need to init a data directory, start postgres, and then go from there.

initdb /some/directory # just do this ONCE
pg_ctl -D /some/directory start # many other options, e.g. logging, available here
psql postgres

You can set an environment variable for the data directory and you won't need the -D flag later. You can look that up later.

jeffmaher
  • 1,824
  • 3
  • 21
  • 20
Andrew Lazarus
  • 18,205
  • 3
  • 35
  • 53