# Can't run my Discourse locally

**URL:** https://meta.discourse.org/t/cant-run-my-discourse-locally/41226
**Category:** Development
**Created:** [March 17, 2016, 7:45pm UTC](https://meta.discourse.org/t/cant-run-my-discourse-locally/41226 "2016-03-17T19:45:45Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![stevenpslade](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stevenpslade/32/53550_2.png) [@stevenpslade](https://meta.discourse.org/u/stevenpslade)
#### Post date: [March 17, 2016, 7:45pm UTC](https://meta.discourse.org/t/cant-run-my-discourse-locally/41226/1 "2016-03-17T19:45:46Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [March 17, 2016, 8:17pm UTC](https://meta.discourse.org/t/cant-run-my-discourse-locally/41226/2 "2016-03-17T20:17:45Z")

</div>

Is PostgreSQL running?

`ps aux | grep postgres`

---

<div class="post-metadata">

### Author: ![stevenpslade](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stevenpslade/32/53550_2.png) [@stevenpslade](https://meta.discourse.org/u/stevenpslade)
#### Post date: [March 17, 2016, 8:19pm UTC](https://meta.discourse.org/t/cant-run-my-discourse-locally/41226/3 "2016-03-17T20:19:22Z")

</div>

> [@Falco](#):
>
> 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`

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [March 17, 2016, 8:28pm UTC](https://meta.discourse.org/t/cant-run-my-discourse-locally/41226/4 "2016-03-17T20:28:54Z")

</div>

So PostgreSQL isn’t running.

Are you using the VirtualBox setup for development?

A `vagrant down` `varagnt up` can solve this.

---

<div class="post-metadata">

### Author: ![stevenpslade](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stevenpslade/32/53550_2.png) [@stevenpslade](https://meta.discourse.org/u/stevenpslade)
#### Post date: [March 17, 2016, 8:30pm UTC](https://meta.discourse.org/t/cant-run-my-discourse-locally/41226/5 "2016-03-17T20:30:26Z")

</div>

I am not using the VirtualBox setup for development.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [March 17, 2016, 8:32pm UTC](https://meta.discourse.org/t/cant-run-my-discourse-locally/41226/6 "2016-03-17T20:32:41Z")

</div>

Did you plain clone Discourse?

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

---

<div class="post-metadata">

### Author: ![stevenpslade](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stevenpslade/32/53550_2.png) [@stevenpslade](https://meta.discourse.org/u/stevenpslade)
#### Post date: [March 17, 2016, 8:38pm UTC](https://meta.discourse.org/t/cant-run-my-discourse-locally/41226/7 "2016-03-17T20:38:25Z")

</div>

> [@Falco](#):
>
> service postgresql start

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

```

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [March 17, 2016, 8:40pm UTC](https://meta.discourse.org/t/cant-run-my-discourse-locally/41226/8 "2016-03-17T20:40:58Z")

</div>

I need mode info about your setup:

- OS

- Installation Method ([Docker](https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md), [Vagrant](https://github.com/discourse/discourse/blob/master/docs/VAGRANT.md), [Advanced Developer](https://github.com/discourse/discourse/blob/master/docs/DEVELOPER-ADVANCED.md))

---

<div class="post-metadata">

### Author: ![stevenpslade](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stevenpslade/32/53550_2.png) [@stevenpslade](https://meta.discourse.org/u/stevenpslade)
#### Post date: [March 17, 2016, 8:45pm UTC](https://meta.discourse.org/t/cant-run-my-discourse-locally/41226/9 "2016-03-17T20:45:14Z")

</div>

OS X El Capitan and I…advanced developer 😳

---

<div class="post-metadata">

### Author: ![stevenpslade](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stevenpslade/32/53550_2.png) [@stevenpslade](https://meta.discourse.org/u/stevenpslade)
#### Post date: [March 17, 2016, 8:59pm UTC](https://meta.discourse.org/t/cant-run-my-discourse-locally/41226/10 "2016-03-17T20:59:09Z")

</div>

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

---

<div class="post-metadata">

### Author: ![stevenpslade](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stevenpslade/32/53550_2.png) [@stevenpslade](https://meta.discourse.org/u/stevenpslade)
#### Post date: [March 17, 2016, 9:25pm UTC](https://meta.discourse.org/t/cant-run-my-discourse-locally/41226/12 "2016-03-17T21:25:23Z")

</div>

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

```

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [March 17, 2016, 9:25pm UTC](https://meta.discourse.org/t/cant-run-my-discourse-locally/41226/13 "2016-03-17T21:25:39Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [March 17, 2016, 9:39pm UTC](https://meta.discourse.org/t/cant-run-my-discourse-locally/41226/14 "2016-03-17T21:39:09Z")

</div>

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

---

<div class="post-metadata">

### Author: ![stevenpslade](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stevenpslade/32/53550_2.png) [@stevenpslade](https://meta.discourse.org/u/stevenpslade)
#### Post date: [March 17, 2016, 9:43pm UTC](https://meta.discourse.org/t/cant-run-my-discourse-locally/41226/15 "2016-03-17T21:43:57Z")

</div>

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

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [March 17, 2016, 9:47pm UTC](https://meta.discourse.org/t/cant-run-my-discourse-locally/41226/16 "2016-03-17T21:47:28Z")

</div>

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

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [March 17, 2016, 10:19pm UTC](https://meta.discourse.org/t/cant-run-my-discourse-locally/41226/17 "2016-03-17T22:19:00Z")

</div>

Make sure you follow the setup database part found at

> [@Install Discourse on Ubuntu or Debian for Development](https://meta.discourse.org/t/beginners-guide-to-install-discourse-on-ubuntu-for-development/14727):
>
> warning This guide covers installation instructions in a development environment. For a production guide see: [Install Discourse in production with the official supported instructions](https://meta.discourse.org/t/how-to-install-discourse-in-production/142537) So you want to set up Discourse on Ubuntu or Debian to hack on and develop with? We’ll assume that you work locally and don’t have Ruby/Rails/Postgres/Redis installed on your Ubuntu or Debian system. Let’s begin! Requirements We suggest having at least 4 GB RAM and 2 CPU cores. Current compatibility: O…

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

---

<div class="post-metadata">

### Author: ![stevenpslade](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stevenpslade/32/53550_2.png) [@stevenpslade](https://meta.discourse.org/u/stevenpslade)
#### Post date: [March 17, 2016, 10:22pm UTC](https://meta.discourse.org/t/cant-run-my-discourse-locally/41226/18 "2016-03-17T22:22:29Z")

</div>

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

---

<div class="post-metadata">

### Author: ![adass](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/adass/32/49627_2.png) [@adass](https://meta.discourse.org/u/adass)
#### Post date: [May 7, 2017, 8:25pm UTC](https://meta.discourse.org/t/cant-run-my-discourse-locally/41226/19 "2017-05-07T20:25:56Z")

</div>

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.
