stevenpslade reported an urgent error while attempting to run Discourse locally on OS X El Capitan using the Advanced Developer setup. Running rails c or accessing localhost:3000 resulted in a PG::ConnectionBad error, indicating the server could not connect to the Unix domain socket /tmp/.s.PGSQL.5432. Although Falco initially suggested verifying if PostgreSQL was running, stevenpslade confirmed the process was not active. Falco recommended starting the service manually, but stevenpslade encountered the same connection failure. After stevenpslade clarified they were using Homebrew (brew install) for PostgreSQL 9.5.1, zogstrip and cpradio emphasized the need to ensure the database server was running and pointed to installation guides. stevenpslade eventually resolved the issue by uninstalling and reinstalling PostgreSQL. Additionally, adass shared a similar experience where the PostgreSQL daemon was stopped but a stale postmaster.pid file prevented restart, which was fixed by removing the file.
URGENT: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Failed to initialize site default
And then opening localhost:3000 I see:
PG::ConnectionBad at /
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket “/tmp/.s.PGSQL.5432”?
The problem is new and I have run my local Discourse fine before.
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
So I’ve deleted my local copy discourse and started from scratch and cloned Discourse. When I bundle exec rake db:create db:migrate db:test:prepare I get the error I was getting before:
URGENT: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Failed to initialize site default
rake aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
@stevenpslade, you need to ensure the postgresql server is running locally. Depending on how you installed it (brew install, http://postgresapp.com/ or anything else) the solution might be different. We need more info about your setup.
I just run into similar issue. For info of others coming here - in my case the postgresql deamon was stopped, but there was a PID file postmaster.pid from previous startup. I fixed this by simpy removing old PID file: rm /usr/local/var/postgres/postmaster.pid. Location of this file is system specific, so please double-check.