Answer a question

Not really sure what caused this but most likely exiting the terminal while my rails server which was connected to PostgreSQL database was closed (not a good practice I know but lesson learned!)

I've already tried the following:

  1. Rebooting my machine (using MBA M1 2020)
  2. Restarting PostgreSQL using homebrew brew services restart postgresql
  3. Re-installing PostgreSQL using Homebrew
  4. Updating PostgreSQL using Homebrew
  5. I also tried following this link but when I run cd Library/Application\ Support/Postgres terminal tells me Postgres folder doesn't exist, so I'm kind of lost already. Although I have a feeling that deleting postmaster.pid would really fix my issue. Any help would be appreciated!

Answers

Below was the workaround if you prefer to stay in v13.3, if you are on 14.2 you can simply change the port postgresql is listening to. Read their docs about it here.

Note that this solution works for the setup that I have (take a look at the original post for my setup details ie. OS & how what I'd use to install Postgres)

  1. open your postgresql.conf file in the following directory and use any text editor you want. below uses vscode/vim.

vscode

sudo code . /usr/local/var/postgres/postgresql.conf

vim

sudo vi /usr/local/var/postgres/postgresql.conf
  1. change port to 5432 and restart your machine.

v13.3 solution

it appears that the upgrade really messed up my postgres since per Nagev's answer it's listening to port 5433 instead of 5432. I downgraded to v13.3 to fix this issue.

brew uninstall postgresql
brew install postgresql@13
brew services start postgresql@13
brew link postgresql@13 --force
Logo

PostgreSQL社区为您提供最前沿的新闻资讯和知识内容

更多推荐