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.
So for a lot of the issues here, it seems that people were already running psql and had to remove postmaster.pid. However, I did not have that issue as I never even had postgres installed in my system properly.
Here's a solution that worked for me in MAC OSX Yosemite
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/binHope this helps! Toodles!
Also, this answer helped me the most: https://stackoverflow.com/a/21503349/3173748