How to fix this error?
psql: error: 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"?
We use Docker, Postgres12, Wercker. When we run this command in Wercker, we can't create a database. But we can create it in my local Ubuntu environment.
sudo docker exec docker_postgres_1 psql -U postgres -c 'create database postgres_dev'
First, you need to make sure the
socket fileis located in/var/run/postgresql/.s.PGSQL.5432. To check thatif result shows something, then the problem is anything else. But, if file is not there you need to check
/tmpdir (specially for OSXHomebrewusers)Now, there are two ways you can solve the error
Solution One
You can change the application configuration to see for sockets at
/tmp/.s.PGSQL.5432For Rails Users
Solution Two
You can create symlinks to the expected location