Configuring Postgresql on OSX Lion

I ran into an issue today while trying to install Postgresql on OSX Lion. I followed the excellent documentation on this site – basically doing:

brew install postgresql

initdb /usr/local/var/postgres

Then starting it with

postgres -D /usr/local/var/postgres

This all went great and my database was up and running! Only problem was when I tried to run a migration against my local instance – I got a page full of errors including:

could not connect to server: Permission denied

Is the server running locally and accepting

connections on Unix domain socket “/var/pgsql_socket/.s.PGSQL.5432”?

Luckily someone has already solved this problem. I followed the instructions on that site (which looked very promising), but I was still stuck with the same problem.

Lucky for me someone in the comments mentioned an additional step you might need to run if you have already run bundler:

gem uninstall pg

gem install pg

Hopefully this will help someone with the same problem. Happy coding.