Have you come across this error before? Postgres is running but you are unable to connect? Well here is the fix!
The issues happens when the Postgres services are stopped in a forceful way, for example, if your mac was to turn off or you have a power cut.
I have this installed with Brew so this is how I fixed the issue,
- First, see if Postgres is running
brew services list
2. If it is running stop it, with the below. This is important as if you don’t stop the services when you get to step 3 this will corrupt your database.
brew services stop postgresql
3. Now, this has stopped you need to remove the postmaster.pid file. This is located here
4. When you have removed this start the service again and you will be able to connect again
brew services start postgresql
If anyone has any issues with this please let me know!