Can't run my Discourse locally


(Steven Slade) #1

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.


(Rafael dos Santos Silva) #2

Is PostgreSQL running?

ps aux | grep postgres


(Steven Slade) #3

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


(Rafael dos Santos Silva) #4

So PostgreSQL isn’t running.

Are you using the VirtualBox setup for development?

A vagrant down varagnt up can solve this.


(Steven Slade) #5

I am not using the VirtualBox setup for development.


(Rafael dos Santos Silva) #6

Did you plain clone Discourse?

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


(Steven Slade) #7

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

(Rafael dos Santos Silva) #8

I need mode info about your setup:


(Steven Slade) #9

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


(Steven Slade) #10

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


(Steven Slade) #12

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

(Rafael dos Santos Silva) #13

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.


(Régis Hanol) #14

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


(Steven Slade) #15

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.


(Régis Hanol) #16

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


(cpradio) #17

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.


(Steven Slade) #18

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


#19

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.