# External postgres setup not working

**URL:** https://meta.discourse.org/t/external-postgres-setup-not-working/259657
**Category:** Self-hosting
**Created:** [March 28, 2023, 7:05am UTC](https://meta.discourse.org/t/external-postgres-setup-not-working/259657 "2023-03-28T07:05:57Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![deepak\_b](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@deepak\_b](https://meta.discourse.org/u/deepak_b)
#### Post date: [March 28, 2023, 7:05am UTC](https://meta.discourse.org/t/external-postgres-setup-not-working/259657/1 "2023-03-28T07:05:57Z")

</div>

We have followed below blog to setup Discourse to use separate postgres(AWS RDS).

> [@Configure Discourse to use a separate PostgreSQL server](https://meta.discourse.org/t/configure-discourse-to-use-a-separate-postgresql-server/46375):
>
> 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 …

Getting below error(image attached) after running ./launcher rebuild app:

```plaintext
Caused by:
PG::InvalidSchemaName: ERROR: no schema has been selected to create in
LINE 1: CREATE TABLE "schema_migrations" ("version" character varyin...
                     ^
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rack-mini-profiler-3.0.0/lib/patches/db/pg.rb:110:in `exec'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rack-mini-profiler-3.0.0/lib/patches/db/pg.rb:110:in `async_exec'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:48:in `block (2 levels) in execute'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.4.3/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.4.3/lib/active_support/dependencies/interlock.rb:41:in `permit_concurrent_loads'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:47:in `block in execute'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.4.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.4.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.4.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.4.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/connection_adapters/abstract_adapter.rb:765:in `block in log'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.4.3/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/connection_adapters/abstract_adapter.rb:756:in `log'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:46:in `execute'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/connection_adapters/abstract/schema_statements.rb:325:in `create_table'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/schema_migration.rb:23:in `create_table'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/migration.rb:1259:in `initialize'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/migration.rb:1117:in `new'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/migration.rb:1117:in `up'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/migration.rb:1092:in `migrate'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/tasks/database_tasks.rb:262:in `migrate'
/var/www/discourse/lib/tasks/db.rake:246:in `block (2 levels) in <main>'
/var/www/discourse/lib/distributed_mutex.rb:53:in `block in synchroniz

```

 ![image](https://global.discourse-cdn.com/meta/original/4X/1/e/8/1e8495c7a47504045c266809e1f113f9e9ec77a7.png)

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [March 28, 2023, 4:17pm UTC](https://meta.discourse.org/t/external-postgres-setup-not-working/259657/2 "2023-03-28T16:17:25Z")

</div>

Without looking too closely, I think that might mean that you created the database server, but didn’t create the discourse database? Or didn’t provide the database name in the settings?

---

<div class="post-metadata">

### Author: ![deepak\_b](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@deepak\_b](https://meta.discourse.org/u/deepak_b)
#### Post date: [March 28, 2023, 4:52pm UTC](https://meta.discourse.org/t/external-postgres-setup-not-working/259657/3 "2023-03-28T16:52:38Z")

</div>

DB setting in app.yml are as below:

env:  
DISCOURSE\_DB\_USERNAME: discourse  
DISCOURSE\_DB\_PASSWORD: “XXX”  
DISCOURSE\_DB\_HOST: [xxx.rds.amazonaws.com](http://xxx.rds.amazonaws.com)  
DISCOURSE\_DB\_NAME: discourse

I am able to connect with this DB using pgAdmin. I have executed below commands in this DB for discourse:

CREATE USER discourse PASSWORD ‘XXX’;  
CREATE DATABASE discourse OWNER discourse;

CREATE EXTENSION hstore;  
CREATE EXTENSION pg\_trgm;

---

<div class="post-metadata">

### Author: ![deepak\_b](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@deepak\_b](https://meta.discourse.org/u/deepak_b)
#### Post date: [March 30, 2023, 4:28am UTC](https://meta.discourse.org/t/external-postgres-setup-not-working/259657/4 "2023-03-30T04:28:27Z")

</div>

Please help on this issue.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [April 11, 2023, 11:54am UTC](https://meta.discourse.org/t/external-postgres-setup-not-working/259657/5 "2023-04-11T11:54:28Z")

</div>

Hello @deepak_b 🙂

You marked this post as the solution. Did you resolve your issue? If you do, can you share how you did? this way it could help other people in the future.
