Can't run my Discourse locally

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.

1 Like

Is PostgreSQL running?

ps aux | grep postgres

1 Like

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.

1 Like

@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.

1 Like

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

6 Likes

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.

1 Like