psql: error: connection to server on socket “/tmp/.s.PGSQL.5432” failed: No such file or directory

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

Leave a Comment