# Configure Discourse to use a separate PostgreSQL server

**URL:** https://meta.discourse.org/t/configure-discourse-to-use-a-separate-postgresql-server/46375
**Category:** Self-Hosting
**Tags:** how-to
**Created:** [6월 23, 2016, 11:48오후 UTC](https://meta.discourse.org/t/configure-discourse-to-use-a-separate-postgresql-server/46375 "2016-06-23T23:48:02Z")
**Posts on this page:** 1
**Showing post:** 24

<div class="post-metadata">

### Author: ![hydrandt](https://avatars.discourse-cdn.com/v4/letter/h/a88e4f/32.png) [@hydrandt](https://meta.discourse.org/u/hydrandt)
#### Post date: [4월 17, 2019, 5:34오전 UTC](https://meta.discourse.org/t/configure-discourse-to-use-a-separate-postgresql-server/46375/24 "2019-04-17T05:34:51Z")

</div>

I needed to run development discourse (set up following [Install Discourse for development using Docker](https://meta.discourse.org/t/beginners-guide-to-install-discourse-for-development-using-docker/102009) ) using database from another container. To do so, I had to modify the installation steps as follows:

1. `git clone https://github.com/discourse/discourse.git`
2. `cd discourse`
3. `vim config/database.yml` , on the top of the file, make it into:

```plaintext
development:
  prepared_statements: false
  adapter: postgresql
  #database: <%= ENV['DISCOURSE_DEV_DB'] || 'discourse_development' %>
  database: discourse
  username: discourse
  password: yourdbpassword
  host: postgres
  min_messages: warning
  pool: 5
  timeout: 5000
  checkout_timeout: <%= ENV['CHECKOUT_TIMEOUT'] || 5 %>
  host_names:
    ### Don't include the port number here. Change the "port" site setting instead, at /admin/site_settings.
    ### If you change this setting you will need to
    ### - restart sidekiq if you change this setting
    ### - rebake all to posts using: `RAILS_ENV=production bundle exec rake posts:rebake`
    - "localhost"

```

1. `vim bin/docker/boot_dev`, find the line starting with `docker run`, and add a network definition matching the docker network to which your postgres container is attached to: `docker run --network my-docker_network-name -d -p 4305:...`
2. `./bin/docker/boot_dev`
3. `./bin/docker/unicorn`
4. you may need to run migrations: `docker exec -it discourse_dev /bin/bash -c "cd /src; ./bin/rails db:migrate RAILS_ENV=development"`
5. visit [http://localhost:9292/](http://localhost:9292/) and log in with credentials you set up earlier on that database

Is there a simpler way to do it, just with environment variables?

---

_[View the full topic](https://meta.discourse.org/t/configure-discourse-to-use-a-separate-postgresql-server/46375)._
