Can't rebuild due to failed postgres 12 upgrade

Which guide?
Port 2045 reminds me of something I can’t pin exactly :thinking:

After few failure installation few months back I changed it to 2045, but this is not relevant since it’s commented with #. The issue is not with that port.

I followed this guide

Well… It was changed, slippery fingers happen :sweat_smile:

I understand, but to come up with 2045 at some point you might have followed something which led you here and now.
I think i followed the same post because i too have a 2045 proxy in my nginx conf for some reason that i can’t remember…


@Benjamin_D there is no 2045 port in my nginx file, you can take a look at it by scrolling up. That line in app.yml is commented by #, so I dont understand why are you guys pointing fingers at it. The issue does not come from there thats for sure, otherwise the error message would point it out.

I can remove that line from the app.yml file if you want, the result would be the same as before.

I think at the time I have installed it for the first time, the container said that the port 80 or 443 are being used so I might read somewhere to just add random port on it but again that line is commented with #, which should not take into account…

Not at all, we are merely trying to retrace your steps and compare our setup with your

This error is definitely related to a failed postgres upgrade.

Check out the meta topic to get the issue fixed.


I will check the postgres upgrade topic. I will came back if I encounter any other error.

So after upgrading postgres from 10 to 12, I still have problems after executing the command: ./launcher rebuild app

sudo ./launcher rebuild app
fatal: not a git repository (or any of the parent directories): .git
Stopping old container
+ /usr/bin/docker stop -t 60 app
cd /pups && git pull && /pups/bin/pups --stdin
Already up to date.
I, [2020-07-13T13:34:21.635079 #1]  INFO -- : Loading --stdin
I, [2020-07-13T13:34:21.643465 #1]  INFO -- : > locale-gen $LANG && update-locale
I, [2020-07-13T13:34:21.713536 #1]  INFO -- : Generating locales (this might take a while)...
Generation complete.

I, [2020-07-13T13:34:21.713917 #1]  INFO -- : > mkdir -p /shared/postgres_run
I, [2020-07-13T13:34:21.720693 #1]  INFO -- :
I, [2020-07-13T13:34:21.721042 #1]  INFO -- : > chown postgres:postgres /shared/postgres_run
I, [2020-07-13T13:34:21.724919 #1]  INFO -- :
I, [2020-07-13T13:34:21.725387 #1]  INFO -- : > chmod 775 /shared/postgres_run
I, [2020-07-13T13:34:21.728768 #1]  INFO -- :
I, [2020-07-13T13:34:21.729117 #1]  INFO -- : > rm -fr /var/run/postgresql
I, [2020-07-13T13:34:21.732712 #1]  INFO -- :
I, [2020-07-13T13:34:21.733008 #1]  INFO -- : > ln -s /shared/postgres_run /var/run/postgresql
I, [2020-07-13T13:34:21.735981 #1]  INFO -- :
I, [2020-07-13T13:34:21.736200 #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/13 13:34:21 socat[27] E connect(6, AF=1 "/shared/postgres_run/.s.PGSQL.5432", 36): No such file or directory
I, [2020-07-13T13:34:21.751266 #1]  INFO -- :
I, [2020-07-13T13:34:21.752242 #1]  INFO -- : > rm -fr /shared/postgres_run/.s*
I, [2020-07-13T13:34:21.757300 #1]  INFO -- :
I, [2020-07-13T13:34:21.757817 #1]  INFO -- : > rm -fr /shared/postgres_run/*.pid
I, [2020-07-13T13:34:21.761287 #1]  INFO -- :
I, [2020-07-13T13:34:21.761706 #1]  INFO -- : > mkdir -p /shared/postgres_run/10-main.pg_stat_tmp
I, [2020-07-13T13:34:21.765114 #1]  INFO -- :
I, [2020-07-13T13:34:21.765725 #1]  INFO -- : > chown postgres:postgres /shared/postgres_run/10-main.pg_stat_tmp
I, [2020-07-13T13:34:21.770573 #1]  INFO -- :
I, [2020-07-13T13:34:21.781057 #1]  INFO -- : File > /etc/service/postgres/run  chmod: +x  chown:
I, [2020-07-13T13:34:21.791681 #1]  INFO -- : File > /etc/service/postgres/log/run  chmod: +x  chown:
I, [2020-07-13T13:34:21.800244 #1]  INFO -- : File > /etc/runit/3.d/99-postgres  chmod: +x  chown:
I, [2020-07-13T13:34:21.808363 #1]  INFO -- : File > /root/upgrade_postgres  chmod: +x  chown:
I, [2020-07-13T13:34:21.809170 #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-13T13:34:21.817357 #1]  INFO -- :

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"]}
** 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.

I don’t get it, I give up… ;/

What means "fatal: not a git repository (or any of the parent directories): .git " ??

Also I get the following

sudo ./discourse-setup
The configuration file containers/app.yml already exists!

. . . reconfiguring . . .

Saving old file as app.yml.2020-07-13-153931.bak
Stopping existing container in 5 seconds or Control-C to cancel.
+ /usr/bin/docker stop -t 10 app

Found 4GB of memory and 2 physical CPU cores
setting db_shared_buffers = 1024MB
containers/app.yml memory parameters updated.

Hostname for your Discourse? []:

Checking your domain name . . .
WARNING: Port 443 of computer does not appear to be accessible using hostname:
WARNING: Connection to (port 80) also fails.

This suggests that resolves to some IP address that does not reach thi  s
machine where you are installing discourse.

The first thing to do is confirm that resolves to the IP address of th  is server.
You usually do this at the same place you purchased the domain.

If you are sure that the IP address resolves correctly, it could be a firewall i  ssue.
A web search for "open ports YOUR CLOUD SERVICE" might help.

This tool is designed only for the most standard installations. If you cannot re  solve
the issue above, you will need to edit containers/app.yml yourself and then type

./launcher rebuild app

The website is up and running secured using port 443 (SSL), I don’t understand why it says it cannot reach the website. I don’t know what else to do anymore. Please help

You have a reverse proxy, so you can’t use discourse-setup. Also, you likely need to remove the let’s encrypt template from your config file.

I don’t know what your postgres problem might be.


You mean those lines about proxy in my nginx file?

Aren’t you trying to re-install discourse “on top” of a previous install (the one in february), thus the existing app.yml from the screenshot of the first post, and the need to upgrade postgresql from 10 to 12 (which I don’t think you did, considering the error message, well maybe you did on your host but not in your data container, which might not exist anymore, I don’t know the state of your previous install) ?
Do you have some backup, do you want a fresh install ?

1 Like

I think @pfaffman means that because your are using a reverse proxy (nginx), the script discourse-setup might not work (I have never run discourse with a reverse proxy, so I don’t know if this is the case). If you define the app.yml correctly it should be fine too, without running discourse-setup.

This seems like it’s trying to execute this code in a container that doesn’t have postgres 10 (you are probably using the version 12). If this is what you want, and your template is templates/postgres.template.yml as defined in your first post, maybe the discourse_docker repository in your machine (at /var/discourse) is outdated.

Is your installed discourse recent or old? It may fix that problem if you update the repository:

cd /var/discourse
git pull

and then run the rebuild step.

Also make sure that the discourse container is destroyed and recreated (and not only stopped and started), to not use an old container (I think the discourse rebuild should already do that, but just in case…).

If it doesn’t work and you have a backup, it is advisable to try to install in a fresh new instance as @Benjamin_D said.

1 Like


I am trying to install discourse for another domain “on top” of my previous install. 2 domains in the same server to be precise. Please forgive my ignorance, in which part of app.yml can I find postgresql? cause I just looked at my app.yml and I don’t see anything related to that.

I do have backups of the old files that I had, I kinda copied some info from my previous install to the new app.yml for the new server.


Here also please forgive my ignorance, are you guys referring to this line when you say “proxy” nginx?

location / {
        proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock;
        proxy_set_header Host $http_host;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Real-IP $remote_addr;

Before I used postgresql 10 but yesterday I have upgraded it to 12.

I would like very much to start a new instance in this case, how can I remove the old ones to make sure that everything will be installed fresh? Thanks a lot

Two discourse instances on the same server, that would be the multisite config, a whole other story :smile:
For know i think it would be best to be sure you have a backup of the first site, have it up and running pg12 upgraded, and then try the multisite adventure for which i’m absolutly not qualified :sweat_smile:


Thanks Benjamin,

I would start fresh, I do have the backup of the first site, however it was a try out and not necessary anymore. I would like to start clean again.

How do I remove the old container and everything so that I can start a new slate?

Have you tried to update the discourse_docker repository locally (at /var/discourse) first? It didn’t work?

About the reverse proxy, it’s because nginx is in the middle of the requests and routing to the correct services (instead of the service, in this case discourse, exposed directly to the internet), so nginx is acting as a reverse proxy and the ports (80 and 443) exposed to the internet belongs to the nginx service.

Strangely the discourse setup worked in February in one of my domain, as you noticed Benjamin remember cause I have also been posting stuff related to that while back ago. So I am surprised that people never ran discourse with nginx. To be honest it worked perfectly fine, until yesterday when I tried to install discourse on another domain using the same server.

What exactly should I look for in discourse_docker? Here is the content of that folder

discourse_docker$ ls
bin   containers        discourse-setup  launcher  scripts  templates
cids  discourse-doctor  image            LICENSE   samples    shared

Just run git pull to update the repository (the /var/discourse directory itself is the local repository), as I said in one of the posts above:

and after it run the rebuild command.

There other people that use nginx in front, but it must be much fewer cases than the standard install in a dedicated machine for discourse only. I also don’t know if it breaks discourse-setup, I’m just guessing based on your results, and given that the error happened when checking DNS and open ports (and having in mind that it is not your discourse container that uses the ports 80 and 443 in the host).

Okay, so I went to the folder discourse_docker as you mentioned Lucas and I copied my app.yml file to the containers of that folder and ran the command ./launcher rebuild app

Something happened without any error and I think it’s working

I don’t want to jinx it yet, I will try to setup the new account now :smiley: