# 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:** 1

<div class="post-metadata">

**Author:** ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)\
**Post date:** [6월 23, 2016, 11:48오후 UTC](https://meta.discourse.org/t/configure-discourse-to-use-a-separate-postgresql-server/46375/1 "2016-06-23T23:48:02Z")

</div>

Let’s say you’re using AWS RDS, or an existing PostgreSQL server managed elsewhere. It’s fairly straightforward to get Discourse to use such a setup, without needing to grant superuser privileges to anything that Discourse itself runs. Here’s how.

## Prerequisites

Discourse requires PostgreSQL’s major version to [match what we ship with in our docker images](https://github.com/discourse/discourse_docker/blob/main/image/base/Dockerfile#L37); if you try to run on a newer or older version, it _might_ work, but we don’t guarantee it, and if something breaks in the future, you get to keep both pieces. We also require some extensions that are distributed in the `postgresql-contrib` package (or its equivalent). You will also need the `pgvector` extension (`postgresql-<version>-pgvector` package), which is required by the Discourse AI plugin that ships with Discourse core.

Randomly generate a password for the connection (20+ characters). In this guide, we’ll use `s3kr1t` as a placeholder.

## Setup the DB

As a database superuser, run the following:

```
CREATE USER discourse PASSWORD 's3kr1t';
CREATE DATABASE discourse OWNER discourse;
\c discourse
CREATE EXTENSION hstore;
CREATE EXTENSION pg_trgm;
CREATE EXTENSION unaccent;
CREATE EXTENSION vector;

```

That’s all that has to be done to prepare the DB for use by Discourse.

## Configure Discourse

Get Discourse setup in the usual way, and then edit `containers/app.yml` as follows:

1. Remove the line `- "templates/postgres.template.yml"` under the `templates` top-level key (towards the top of the file);

2. Under the `env` top-level key, set the following:

3. You also need to set the following if your database doesn’t use the default port (5432):

4. Rebuild with `./launcher rebuild app`, and you should be good to go.

> Last edited by @supermathie 2026-02-19T21:46:00Z
> 
> > **Check document**
> >
> > Perform check on document:

---

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