I'm getting a common Mac OSX error for Homebrew installations of Postgres,
No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
This is apparently due to there being multiple installs on the system. However, the usual steps are not resolving things.
I can successfully start Postgres and running:
ps auxw | grep post
returns ..
euanmillar 847 0.0 0.0 2432768 588 s000 R+ 11:19am 0:00.00 grep postgres
euanmillar 845 0.0 0.0 2439324 448 ?? Ss 11:19am 0:00.00 postgres:
stats collector process
euanmillar 844 0.0 0.0 2443176 1520 ?? Ss 11:19am 0:00.00 postgres:
autovacuum launcher process
euanmillar 843 0.0 0.0 2443044 544 ?? Ss 11:19am 0:00.00 postgres: wal writer process
euanmillar 842 0.0 0.0 2443044 584 ?? Ss 11:19am 0:00.00 postgres: writer process
euanmillar 841 0.0 0.0 2443044 596 ?? Ss 11:19am 0:00.00 postgres: checkpointer process
euanmillar 839 0.0 0.0 2443044 3616 s000 S 11:19am 0:00.02 /us
so it looks like postgres is running.
I have commented in the following lines in postgresql.conf
port = 5432
unix_socket_directory = '/var/pgsql_socket'
unix_socket_permissions = 0777
and in var/pgsql_socket/ I do have a hidden file .s.PGSQL.5432
I have tried solutions to many of the posts here. This one especially seems similar:
https://dba.stackexchange.com/questions/21587/postgresql-is-running-locally-but-i-cannot-connect-why
But the difference is that I do have a '/var/pgsql_socket' directory which is CHOWN-ed to everyone. I have used Homebrew to completely remove and re-install Postgres and still I have the same issue.
How do I connect to postgres port 5432? If you are trying to connect to a Postgres instance on the same host as your terminal, you can run lsof -p :5432 which will show which, if any, processes are listening on that port. The postgres process should be connected there.
This will start up a postgres server hosted locally on port 5432. The server will be run out of the directory /usr/local/var/postgres . This will connect to the server and access the postgres database.
“Could not connect to server: Connection refused” To be sure that PostgreSQL is running, you can also restart it with systemctl restart postgresql. If this does not fix the problem, the most likely cause of this error is that PostgreSQL is not configured to allow TCP/IP connections.
You need to remove the postmaster.pid, which should be in the following path:
/usr/local/var/postgres/postmaster.pid
A simpler solution is to locate where the socket actually is vs where it's expected to be. In my case, I ran:
$ locate PGSQL.5432
/private/var/pgsql_socket/.s.PGSQL.5432
/private/var/pgsql_socket/.s.PGSQL.5432.lock
Then just symlink the expected socket location to the actual socket location.
$ ln -s /private/var/pgsql_socket/.s.PGSQL.5432 /tmp/.s.PGSQL.5432
For me, i removed postmaster.pid in /usr/local/var/postgres
. fixed me right up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With