# Running discourse with Postgres running in docker

**URL:** <https://meta.discourse.org/t/running-discourse-with-postgres-running-in-docker/216803>\
**Category:** Development\
**Created:** [February 2, 2022, 6:21am UTC](https://meta.discourse.org/t/running-discourse-with-postgres-running-in-docker/216803 "2022-02-02T06:21:15Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![abdellani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/abdellani/32/245154_2.png) [@abdellani](https://meta.discourse.org/u/abdellani)\
**Post date:** [February 2, 2022, 6:21am UTC](https://meta.discourse.org/t/running-discourse-with-postgres-running-in-docker/216803/1 "2022-02-02T06:21:15Z")

</div>

Hi

I’m trying to set up discourse in my local development environment with only a small difference: I’m running Postgres in docker.

The database is accessible using psql from the OS, but when I tried to create the database using rake or rails, it doesn’t work. I followed these steps:

```plaintext
cp discourse_defaults.conf discourse.conf

```

then updated discourse.conf

```plaintext
...
db_host = 127.0.0.1
...
db_username = postgres
db_password = mysecretpassword
...

```

but when I try to run db:create

```plaintext
connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
	Is the server running locally and accepting connections on that socket?
Couldn't create 'discourse_development' database. Please check your configuration.
rails aborted!
ActiveRecord::NoDatabaseError: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
	Is the server running locally and accepting connections on that socket?

Caused by:
PG::ConnectionBad: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
	Is the server running locally and accepting connections on that socket?

Tasks: TOP => db:create
(See full trace by running task with --trace)

```

I tried with .env

```plaintext
DISCOURSE_DB_HOST=127.0.0.1
DISCOURSE_DB_USERNAME=postgres
DISCOURSE_DB_PASSWORD=mysecretpassword

```

I also tried with different IP addresses for ‘DB\_HOST’, but I’m still getting the same error.

Is there something that I’m missing?

---

_[View the full topic](https://meta.discourse.org/t/running-discourse-with-postgres-running-in-docker/216803)._
