# Can't rebuild due to failed postgres 12 upgrade

**URL:** <https://meta.discourse.org/t/cant-rebuild-due-to-failed-postgres-12-upgrade/157428>\
**Category:** Self-hosting\
**Created:** [11 ביולי,‏ 2020,‏ 1:43am UTC](https://meta.discourse.org/t/cant-rebuild-due-to-failed-postgres-12-upgrade/157428 "2020-07-11T01:43:47Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![pr0cesor](https://avatars.discourse-cdn.com/v4/letter/p/977dab/32.png) [@pr0cesor](https://meta.discourse.org/u/pr0cesor)\
**Post date:** [11 ביולי,‏ 2020,‏ 1:43am UTC](https://meta.discourse.org/t/cant-rebuild-due-to-failed-postgres-12-upgrade/157428/1 "2020-07-11T01:43:47Z")

</div>

Hi there,

I am stuck with the following. When executing the commande ./discourse-setup, I have the following error

 ![disc1](https://global.discourse-cdn.com/meta/original/3X/0/6/06fe7fbdf4a01a0320ca3adb362f912d5a7af5c3.jpeg)

Im not sure I understand the message, my website is live and running [https://cp2077.eu/](https://cp2077.eu/) with SSL.

Here is my app.yml

```
## this is the all-in-one, standalone Discourse Docker container template
##
## After making changes to this file, you MUST rebuild
## /var/discourse/launcher rebuild app
##
## BE *VERY* CAREFUL WHEN EDITING!
## YAML FILES ARE SUPER SUPER SENSITIVE TO MISTAKES IN WHITESPACE OR ALIGNMENT!
## visit http://www.yamllint.com/ to validate this file as needed

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/sshd.template.yml"
  - "templates/web.ratelimited.template.yml"
## Uncomment these two lines if you wish to add Lets Encrypt (https)
## - "templates/web.ssl.template.yml"
## - "templates/web.letsencrypt.ssl.template.yml"
  - "templates/web.socketed.template.yml"
## which TCP/IP ports should this container expose?
## If you want Discourse to share a port with another webserver like Apache or nginx,
## see https://meta.discourse.org/t/17247 for details
#expose:
# - "2045:80" # http
# - "1443:443" # https

params:
  db_default_text_search_config: "pg_catalog.english"

  ## Set db_shared_buffers to a max of 25% of the total memory.
  ## will be set automatically by bootstrap based on detected RAM, or you can override
  db_shared_buffers: "1024MB"

  ## can improve sorting performance, but adds memory usage per-connection
  #db_work_mem: "40MB"

  ## Which Git revision should this container use? (default: tests-passed)
  #version: tests-passed

env:
  LANG: en_US.UTF-8
  # DISCOURSE_DEFAULT_LOCALE: en

  ## How many concurrent web requests are supported? Depends on memory and CPU cores.
  ## will be set automatically by bootstrap based on detected CPUs, or you can override
  UNICORN_WORKERS: 4

  ## TODO: The domain name this Discourse instance will respond to
  ## Required. Discourse will not work with a bare IP number.
  DISCOURSE_HOSTNAME: cp2077.eu

  ## Uncomment if you want the container to be started with the same
  ## hostname (-h option) as specified above (default "$hostname-$config")
  #DOCKER_USE_HOSTNAME: true

  ## TODO: List of comma delimited emails that will be made admin and developer
  ## on initial signup example 'user1@example.com,user2@example.com'
  DISCOURSE_DEVELOPER_EMAILS: 'myemail@yandex.com'

  ## TODO: The SMTP mail server used to validate new accounts and send notifications
  # SMTP ADDRESS, username, and password are required
  # WARNING the char '#' in SMTP password can cause problems!
  DISCOURSE_SMTP_ADDRESS: smtp.mailgun.org
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: ******
  DISCOURSE_SMTP_PASSWORD: ******
  DISCOURSE_SMTP_ENABLE_START_TLS: true # (optional, default true)

  ## If you added the Lets Encrypt template, uncomment below to get a free SSL certificate
  LETSENCRYPT_ACCOUNT_EMAIL: myemail@yandex.com

  ## The http or https CDN address for this Discourse instance (configured to pull)
  ## see https://meta.discourse.org/t/14857 for details
  #DISCOURSE_CDN_URL: https://discourse-cdn.example.com

## The Docker container is stateless; all data is stored in /shared
volumes:
  - volume:
 host: /var/discourse/shared/standalone
  guest: /shared
  - volume:
  host: /var/discourse/shared/standalone/log/var-log
  guest: /var/log

## Plugins go here
## see https://meta.discourse.org/t/19157 for details
hooks:
  after_code:
- exec:
    cd: $home/plugins
    cmd:
      - git clone https://github.com/discourse/docker_manager.git

## Any custom commands to run after building
run:
  - exec: echo "Beginning of custom commands"
  ## If you want to set the 'From' email address for your first registration, uncomment and change:
  ## After getting the first signup email, re-comment the line. It only needs to run once.
  ## - exec: rails r "SiteSetting.notification_email='beatlicious@yandex.com'"
  - exec: echo "End of custom commands"

```

When I do the command ./launcher rebuild app, I have the following error:

```
fatal: not a git repository (or any of the parent directories): .git
Stopping old container
+ /usr/bin/docker stop -t 60 app
app
cd /pups && git pull && /pups/bin/pups --stdin
Already up to date.
I, [2020-07-11T01:41:07.468750 #1] INFO -- : Loading --stdin
I, [2020-07-11T01:41:07.482322 #1] INFO -- : > locale-gen $LANG && update-locale
I, [2020-07-11T01:41:07.556578 #1] INFO -- : Generating locales (this might take a while)...
Generation complete.

I, [2020-07-11T01:41:07.557419 #1] INFO -- : > mkdir -p /shared/postgres_run
I, [2020-07-11T01:41:07.562170 #1] INFO -- :
I, [2020-07-11T01:41:07.562833 #1] INFO -- : > chown postgres:postgres /shared/postgres_run
I, [2020-07-11T01:41:07.568411 #1] INFO -- :
I, [2020-07-11T01:41:07.569223 #1] INFO -- : > chmod 775 /shared/postgres_run
I, [2020-07-11T01:41:07.576449 #1] INFO -- :
I, [2020-07-11T01:41:07.577398 #1] INFO -- : > rm -fr /var/run/postgresql
I, [2020-07-11T01:41:07.582904 #1] INFO -- :
I, [2020-07-11T01:41:07.583623 #1] INFO -- : > ln -s /shared/postgres_run /var/run/postgresql
I, [2020-07-11T01:41:07.592257 #1] INFO -- :
I, [2020-07-11T01:41:07.593134 #1] INFO -- : > socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container ; exit 1
2020/07/11 01:41:07 socat[27] E connect(6, AF=1 "/shared/postgres_run/.s.PGSQL.5432", 36): No such file or directory
I, [2020-07-11T01:41:07.602436 #1] INFO -- :
I, [2020-07-11T01:41:07.602977 #1] INFO -- : > rm -fr /shared/postgres_run/.s*
I, [2020-07-11T01:41:07.608907 #1] INFO -- :
I, [2020-07-11T01:41:07.609638 #1] INFO -- : > rm -fr /shared/postgres_run/*.pid
I, [2020-07-11T01:41:07.619803 #1] INFO -- :
I, [2020-07-11T01:41:07.622598 #1] INFO -- : > mkdir -p /shared/postgres_run/10-main.pg_stat_tmp
I, [2020-07-11T01:41:07.629638 #1] INFO -- :
I, [2020-07-11T01:41:07.630522 #1] INFO -- : > chown postgres:postgres /shared/postgres_run/10-main.pg_stat_tmp
I, [2020-07-11T01:41:07.639523 #1] INFO -- :
I, [2020-07-11T01:41:07.651076 #1] INFO -- : File > /etc/service/postgres/run chmod: +x chown:
I, [2020-07-11T01:41:07.660620 #1] INFO -- : File > /etc/service/postgres/log/run chmod: +x chown:
I, [2020-07-11T01:41:07.668238 #1] INFO -- : File > /etc/runit/3.d/99-postgres chmod: +x chown:
I, [2020-07-11T01:41:07.679949 #1] INFO -- : File > /root/upgrade_postgres chmod: +x chown:
I, [2020-07-11T01:41:07.680746 #1] INFO -- : > chown -R root /var/lib/postgresql/10/main
chown: cannot access '/var/lib/postgresql/10/main': No such file or directory
I, [2020-07-11T01:41:07.685326 #1] INFO -- :

FAILED
--------------------
Pups::ExecError: chown -R root /var/lib/postgresql/10/main failed with return #<Process::Status: pid 42 exit 1>
Location of failure: /pups/lib/pups/exec_command.rb:112:in `spawn'
exec failed with the params {"cmd"=>["chown -R root /var/lib/postgresql/10/main", "[! -e /shared/postgres_data] && install -d -m 0755 -o postgres -g postgres /shared/postgres_data && sudo -E -u postgres /usr/lib/postgresql/10/bin/initdb -D /shared/postgres_data || exit 0", "chown -R postgres:postgres /shared/postgres_data", "chown -R postgres:postgres /var/run/postgresql"]}
d639e83f5451b5039efb2333f3eca1166d34ff6dc582ee29a0734a4274080fa2
**FAILED TO BOOTSTRAP** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
atlas@sknet:~/www/cp2077$

```

Can someone advise me how can I install and setup discourse? I followed the guide and stuck here. Thank you

---

_[View the full topic](https://meta.discourse.org/t/cant-rebuild-due-to-failed-postgres-12-upgrade/157428)._
