Can't run my Discourse locally

AI-generated summary

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.

I go rails c then I get this…

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.

Is PostgreSQL running?

ps aux | grep postgres

I get this:

1280 0.0 0.0 2423376 208 s000 R+ 1:18pm 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn postgres

So PostgreSQL isn’t running.

Are you using the VirtualBox setup for development?

A vagrant down varagnt up can solve this.

I am not using the VirtualBox setup for development.

Did you plain clone Discourse?

Try to start PostgreSQL service, depends on your distro: service postgresql start or somenthing along this lines.

I get the same error as when starting rails:

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"?

I need mode info about your setup:

OS X El Capitan and I…advanced developer :flushed:

RAILS_ENV=production bundle exec rake db:migrate will not even run, because of db:migrate …obviously something screwed up with my postgresql

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"?

Sorry I don’t want to be rude, but if you aren’t an advanced developer maybe try the vagrant one?

I use it, and it’s very nice, and keeps everything in one place and just works!

PS.: I use Linux, so I can’t really follow up you on OS X.

@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 installed it using brew install.

postgres -V returns postgres (PostgreSQL) 9.5.1.

ls -l /tmp/.s.PGSQL.5432 returns ls: /tmp/.s.PGSQL.5432: No such file or directory.

Can you connect to it using psql? Can you list the databases? Can you create one?

Make sure you follow the setup database part found at

As it seems like you are trying to run it outside of Docker and outside of Vagrant.

I uninstalled postres and installed/set it up again. All good now.

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.