I'm trying to run psql
on my Vagrant machine, but I get this error:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting connections on
Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Note: Vagrant 1.9.2 Box: ubuntu/trusty64, https://atlas.hashicorp.com/ubuntu/boxes/trusty64
EDIT Commands I've used in order to install and run postgres:
sudo apt-get update
sudo apt-get install postgresql
sudo su postgres
psql -d postgres -U postgres
Does the
/etc/postgresql/9.6/main/postgresql.conf
show that port being assigned? On my default Xubuntu Linux install, mine showed port = 5433 for some reason as best as I can remember, but I did comment out the line in that same file that saidlisten_addresses = 'localhost'
and uncommented the linelisten_addresses = '*'
. So maybe start and check there. Hope that helps.Within zsh:
This is the only thing that worked for me after countless hours trouble shooting.
I was able to solve the issue by running:
I had similar problems just a while ago. After trying more than 5 suggestions I decided to go back to the basics and start from the beginning. Which meant removing my postgresql installation and following this guide upon re-installing postgresql. https://help.ubuntu.com/lts/serverguide/postgresql.html
This error happened to me after my mac mini got un-plugged (so forced shutdown), and all I had to do to fix it was restart
I had the same issue but non of the answers here helped.
How I fixed it (mac)
pg_ctl -D /usr/local/var/postgres start
FATAL: could not open directory "pg_tblspc": No such file or directory
.mkdir /usr/local/var/postgres/pg_tblspc
FATAL: lock file "postmaster.pid" already exists
rm /usr/local/var/postgres/postmaster.pid
pg_ctl -D /usr/local/var/postgres start