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!
I had this very problem with Mountain Lion but the only thing that worked for me was this fix:
Check where the actual target is:
I needed to create this directory:
Then using the result from the find above create this symlink:
I suspect that for most people on Mountain Lion you can just create the dir and do the symlink and not waste time doing the find unless the symlink doesn't work.
PS - my PostgreSQL was installed through the official installer.
My PostgreSQL is installed in /Library/PostgreSQL so that /usr/var stuff didn't work for me.
It appears that Woz is correct because everytime I close my macbook pro's lid it crashes... Here is what worked post-crash for me:
You may need to specify the host of your database.
I ran into this as well, but I had installed postgres myself (not with homebrew). If that's the case, you need to find the old path to psql (which may be /usr/local/bin, but for me was /usr/local/pgsql/bin) and prepend that to your $PATH.
(before)
which psql
=> /usr/bin/psql(fix) export PATH=/usr/local/psql/bin:$PATH
(after) `which psql' => /usr/local/psql/bin
John Wang's suggestion to
source ~/.bash_rc
afterward you add that to your bash_rc is golden.For those of you who are interested, I pieced together the solution. All I needed was to add
to the database.yml for my environment and all was gravy.
I had the same issue and was having problems making John Wang's solution work. As Darren noted there's an issue with the pg gem. To get it work I needed to:
Then reinstall.
Which got it working.