Like some others I am getting this error when I run rake db:migrate in my project or even try most database tasks for my Ruby on Rails 3.2 applications.
For me, this works
rm /usr/local/var/postgres/postmaster.pid