I recently upgraded to OSX 10.7, at which point my rails installation completely borked when trying to connect to the psql server. When I do it from the command line using
psql -U postgres
it works totally fine, but when I try to run the rails server or console with the same username and password, I get this error
...activerecord-3.0.9/lib/active_record/connection_adapters/postgresql_adapter.rb:950:in `initialize': could not connect to server: Permission denied (PGError)
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
Any ideas what might be going on would be super helpful! Thanks!
Is this for homebrew? Ports seems to put it in:
So make sure you use export
Mac ports issue: https://trac.macports.org/ticket/30125
Another possible solution that worked for me is resetting the postmaster file by deleting it. Simply run:
It's worth checking the log for errors which you can find here:
The error message I was having was:
Everything worked great afterwards.
I'm new to Rails, but adding the following to database.yml worked for me:
Not sure why Rails defaults to domain sockets instead of TCP, while PostgreSQL does not set up domain sockets by default.
If you like a permanent change in your $PATH try this:
this will rewrite your
~/.MacOSX/environment.plist
.For those who installed direct from the official installer, just adding the host to the command works with no path changes:
If the problem persists past changing the path (as it did for me), also try this...
It appears that the problem (partially) lies in the pg gem itself. When it builds, it figures out where the domain socket should be. If you change the location of the domain socket after the fact it doesn't seem to take effect until you rebuild the gem.