I was trying to run heroku local or heroku local web and everything was working fine. After importing the data from my heroku remote to my local environment, it started to throw me the following error:

After searching for the solution in some places, I tried restarting the postgresql service with brew services restart postgresql and it started normally but I kept receiving the error. I also tried to delete the postmaster.pid as suggested on this SO post PG::ConnectionBad - could not connect to server: Connection refused but didn't find the file.
 
    