# Database shut down error at the end of discourse docker setup

**URL:** <https://meta.discourse.org/t/database-shut-down-error-at-the-end-of-discourse-docker-setup/164383>\
**Category:** Self-hosting\
**Created:** [September 17, 2020, 8:04pm UTC](https://meta.discourse.org/t/database-shut-down-error-at-the-end-of-discourse-docker-setup/164383 "2020-09-17T20:04:04Z")\
**Posts on this page:** 7\
**Page:** 1

## AI-generated summary

A user is setting up Discourse on AWS EC2 and encounters a database shutdown error during the Docker setup process. The logs show the PostgreSQL database shutting down as part of the process, but no actual error is visible. The user is concerned about email delivery issues, which are later identified as the real problem. The issue is traced to SendGrid, where the user needs to regenerate the API key by revoking the old one and creating a new application secret. Despite this, email delivery remains broken, prompting the user to seek further troubleshooting steps. [shoaib_mohammed](/t/-/164383/1) initially thought the database shutdown was an error, but the real issue is with email configuration. [riking](/t/-/164383/2) guides the user to regenerate the SendGrid API key and suggests consulting a troubleshooting guide for email issues on Discourse.

<div class="post-metadata">

**Author:** ![shoaib\_mohammed](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shoaib\_mohammed](https://meta.discourse.org/u/shoaib_mohammed)\
**Post date:** [September 17, 2020, 8:04pm UTC](https://meta.discourse.org/t/database-shut-down-error-at-the-end-of-discourse-docker-setup/164383/1 "2020-09-17T20:04:04Z")

</div>

Hi team, I am trying to run the docker discourse set up on AWS EC2 by following this [How to configure Discourse on Amazon Web services (AWS) - Axel Fernandes's blog](https://www.axelfernandes.com/how-to-configure-discourse-on-amazon-web-services-aws)

Everything except the last step went fine. Can you please suggest what is the error?

```
I, [2020-09-17T19:56:38.330642 #1] INFO -- : File > /etc/nginx/letsencrypt.conf chmod: chown: 
I, [2020-09-17T19:56:38.334734 #1] INFO -- : File > /etc/runit/1.d/letsencrypt chmod: +x chown: 
I, [2020-09-17T19:56:38.334916 #1] INFO -- : Replacing (?-mix:ssl_certificate.+) with ssl_certificate /shared/ssl/$$ENV_DISCOURSE_HOSTNAME.cer;
ssl_certificate /shared/ssl/$$ENV_DISCOURSE_HOSTNAME_ecc.cer;
 in /etc/nginx/conf.d/discourse.conf
I, [2020-09-17T19:56:38.335173 #1] INFO -- : Replacing (?-mix:#?ACCOUNT_EMAIL=.+) with ACCOUNT_EMAIL=$$ENV_LETSENCRYPT_ACCOUNT_EMAIL
 in /shared/letsencrypt/account.conf
I, [2020-09-17T19:56:38.335395 #1] INFO -- : Replacing (?-mix:ssl_certificate_key.+) with ssl_certificate_key /shared/ssl/$$ENV_DISCOURSE_HOSTNAME.key;
ssl_certificate_key /shared/ssl/$$ENV_DISCOURSE_HOSTNAME_ecc.key;
 in /etc/nginx/conf.d/discourse.conf
I, [2020-09-17T19:56:38.335982 #1] INFO -- : Replacing (?-mix:add_header.+) with add_header Strict-Transport-Security 'max-age=63072000'; in /etc/nginx/conf.d/discourse.conf
I, [2020-09-17T19:56:38.336602 #1] INFO -- : Replacing location @discourse { with location @discourse {
add_header Strict-Transport-Security 'max-age=31536000'; # remember the certificate for a year and automatically connect to HTTPS for this domain in /etc/nginx/conf.d/discourse.conf
I, [2020-09-17T19:56:38.337288 #1] INFO -- : > echo "Beginning of custom commands"
I, [2020-09-17T19:56:38.339060 #1] INFO -- : Beginning of custom commands

I, [2020-09-17T19:56:38.339171 #1] INFO -- : > echo "End of custom commands"
I, [2020-09-17T19:56:38.340989 #1] INFO -- : End of custom commands

I, [2020-09-17T19:56:38.341091 #1] INFO -- : Terminating async processes
I, [2020-09-17T19:56:38.341176 #1] INFO -- : Sending INT to HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgre
sql/12/bin/postmaster -D /etc/postgresql/12/main pid: 49
2020-09-17 19:56:38.341 UTC [49] LOG: received fast shutdown request
I, [2020-09-17T19:56:38.341692 #1] INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 166
166:signal-handler (1600372598) Received SIGTERM scheduling shutdown...
2020-09-17 19:56:38.344 UTC [49] LOG: aborting any active transactions
2020-09-17 19:56:38.347 UTC [49] LOG: background worker "logical replication launcher" (PID 58) exited with exit code 1
2020-09-17 19:56:38.349 UTC [53] LOG: shutting down
2020-09-17 19:56:38.416 UTC [49] LOG: database system is shut down
166:M 17 Sep 2020 19:56:38.419 # User requested shutdown...
166:M 17 Sep 2020 19:56:38.419 * Saving the final RDB snapshot before exiting.
166:M 17 Sep 2020 19:56:38.423 * DB saved on disk
166:M 17 Sep 2020 19:56:38.424 # Redis is now ready to exit, bye bye...
sha256:80ffaa9115dbe8b1cfdc8d77dd25054e4fbd6be896fa19f6330448110e2e7251
68b73bf7854c91ff7e9cc5c7748e2826a85e6a6cdb62508d4b26cc9fc4cfd12d
Removing old container
+ /usr/bin/docker rm app
app

+ /usr/bin/docker run --shm-size=512m -d --restart=always -e LANG=en_US.UTF-8 -e RAILS_ENV=production -e UNICORN_WORKERS=4 -e UNICORN_SIDEKIQS=1 -e RUBY_GLOBAL_METHOD_CACHE_SIZE=131072 -e
 RUBY_GC_HEAP_GROWTH_MAX_SLOTS=40000 -e RUBY_GC_HEAP_INIT_SLOTS=400000 -e RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=1.5 -e DISCOURSE_DB_SOCKET=/var/run/postgresql -e DISCOURSE_DB_HOST= -e DISCO
URSE_DB_PORT= -e LETSENCRYPT_DIR=/shared/letsencrypt -e DISCOURSE_HOSTNAME=testdiscourse.com -e DISCOURSE_DEVELOPER_EMAILS=sho_xxxxxx_92@gmail.com -e DISCOURSE_SMTP_ADDRESS=smtp.sendgr
id.net -e DISCOURSE_SMTP_PORT=587 -e DISCOURSE_SMTP_USER_NAME=SG.xxxxxx -e DISCOURSE_SMTP_PASSWORD=SG.xxxxxx -e LETSENCRYPT_ACCOUNT_EMAIL=me@example.com -h ip-172-31-4-9-app -e DOCKER_HOST_IP=172.17.0.1 --name app -t -p 80:80 -p 443:443 -v /var/discourse
/shared/standalone:/shared -v /var/discourse/shared/standalone/log/var-log:/var/log --mac-address 02:3a:b7:1a:8e:ae local_discourse/app /sbin/boot

```

---

<div class="post-metadata">

**Author:** ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)\
**Post date:** [September 17, 2020, 8:29pm UTC](https://meta.discourse.org/t/database-shut-down-error-at-the-end-of-discourse-docker-setup/164383/2 "2020-09-17T20:29:17Z")

</div>

I don’t see any actual error in that log. It might be farther up or farther down.

> [@shoaib\_mohammed](#):
>
> `DISCOURSE_SMTP_PASSWORD=`

I have removed the password from your post, but you should go to SendGrid and cycle the application secret.

> [@shoaib\_mohammed](#):
>
> `DISCOURSE_HOSTNAME=testdiscourse.com`

You should be using a domain name you control.

---

<div class="post-metadata">

**Author:** ![shoaib\_mohammed](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shoaib\_mohammed](https://meta.discourse.org/u/shoaib_mohammed)\
**Post date:** [September 17, 2020, 8:33pm UTC](https://meta.discourse.org/t/database-shut-down-error-at-the-end-of-discourse-docker-setup/164383/3 "2020-09-17T20:33:22Z")

</div>

@riking you are right. There is no actual error as such. But the send grid has an issue. Below is the config. What could be the issue ? Can you please explain what you meant cycle the application secret ? You mean to recreate ?

DISCOURSE\_SMTP\_ADDRESS: [smtp.sendgrid.net](http://smtp.sendgrid.net)  
DISCOURSE\_SMTP\_PORT: 2525  
DISCOURSE\_SMTP\_USER\_NAME: apiKey  
DISCOURSE\_SMTP\_PASSWORD: “SG.N6X4OZGjS\_xxxxxx”

---

<div class="post-metadata">

**Author:** ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)\
**Post date:** [September 17, 2020, 8:40pm UTC](https://meta.discourse.org/t/database-shut-down-error-at-the-end-of-discourse-docker-setup/164383/4 "2020-09-17T20:40:01Z")

</div>

Wait, so email sending was the original issue?

Yes, you need to go to the SendGrid console, “revoke” the previous password you were using, and create a new one.

---

<div class="post-metadata">

**Author:** ![shoaib\_mohammed](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shoaib\_mohammed](https://meta.discourse.org/u/shoaib_mohammed)\
**Post date:** [September 17, 2020, 8:42pm UTC](https://meta.discourse.org/t/database-shut-down-error-at-the-end-of-discourse-docker-setup/164383/5 "2020-09-17T20:42:03Z")

</div>

@riking There was no such issue actually initially. The log made me worried. But then i realised emails are not getting delivered.

---

<div class="post-metadata">

**Author:** ![shoaib\_mohammed](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shoaib\_mohammed](https://meta.discourse.org/u/shoaib_mohammed)\
**Post date:** [September 17, 2020, 8:55pm UTC](https://meta.discourse.org/t/database-shut-down-error-at-the-end-of-discourse-docker-setup/164383/6 "2020-09-17T20:55:31Z")

</div>

@riking email seems to be still broken even after the new key. anything else should be taken care ?

---

<div class="post-metadata">

**Author:** ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)\
**Post date:** [September 17, 2020, 8:58pm UTC](https://meta.discourse.org/t/database-shut-down-error-at-the-end-of-discourse-docker-setup/164383/7 "2020-09-17T20:58:27Z")

</div>

Take a look at this #howto guide and see if the steps there resolve the issue.

> [@Troubleshoot email on a new Discourse install](https://meta.discourse.org/t/troubleshooting-email-on-a-new-discourse-install/16326/):
>
> You just installed Discourse via [the install guide](https://github.com/discourse/discourse/blob/main/docs/INSTALL.md), but email doesn’t seem to work. Unfortunately this means you can’t log in as an admin to finalize the install. cry Let’s troubleshootize! Try the doctor woman_health_workerIf you run ./discourse-doctor it will check several ways that your mail configuration might be broken, and offer advice. Try that first. Did you enter email settings correctly? The simplest way is to run ./discourse-setup again. Did you enter everything correctly? B…
