Question

This is the third time I'm setting up Postgres on a new machine (OS X 10.9 this time), and the third time I'm having problems with the connection.

Basically, I'm at the point where I've created a database cluster and can start postgres using:

postgres -D /usr/local/pgsql/data

But I want it to run in the background as a launch daemon, so I

sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql91-server.plist

It seems like the daemon is launched successfully. But when I type psql I get the same old error message I've been dealing with every single time I try to set up Postgres:

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"?

Any ideas on what might be causing this?

Was it helpful?

Solution

The psql you're running is the old version bundled by Apple in Mac OS X and added to the default PATH. Use the one from Homebrew, by fixing your path or entering the path specifically.

Alternately, explicitly connect to the server by overriding the default socket directory:

psql -h /tmp

See also:

Update:

In this case it looks like the server is genuinely not starting. Check the permissions on the data directory (apparently /usr/local/pgsql/data) and check the Console.app logs for relevant messages from launchd.

Update:

You must fix the permissions so the postgres user (or postgres_, depending on how you installed) has ownership. Check the launchd config file to see what user it runs as, and sudo chown -R postgres /usr/local/pgsql/data to change ownership. Replace postgres with postgres_ if that's what your launchd config says

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top