FAILED TO BOOTSTRAP, even on a fresh installation

Hi,

I had been using Discourse for quite many years but I wanted to migrate to a different server.
Already did the backup and now trying to install a new copy on the new server in order to make restoration.

But when I trying to make the new installation, it kept coming up with error.
Tried several times but still the same, already rebuilt the server multiple times it’s the same.

Debian 11
RAM 1GB
SWAP 4GB
2 Core

Installation log:

x86_64 arch detected.
Ensuring launcher is up to date
Fetching origin
Launcher is up-to-date
Stopping old container
+ /usr/bin/docker stop -t 60 app
app
2.0.20230222-0048: Pulling from discourse/base
Digest: sha256:6a7dd0755c6832e1ecfc8cc980f27836b69b4162d6ff1b6a3e4e382a3b854803
Status: Image is up to date for discourse/base:2.0.20230222-0048
docker.io/discourse/base:2.0.20230222-0048
/usr/local/lib/ruby/gems/3.2.0/gems/pups-1.1.1/lib/pups.rb
/usr/local/bin/pups --stdin
I, [2023-03-13T11:25:13.229925 #1]  INFO -- : Reading from stdin
I, [2023-03-13T11:25:13.237120 #1]  INFO -- : > locale-gen $LANG && update-locale
I, [2023-03-13T11:25:15.133566 #1]  INFO -- : Generating locales (this might take a while)...
Generation complete.

I, [2023-03-13T11:25:15.134390 #1]  INFO -- : > mkdir -p /shared/postgres_run
I, [2023-03-13T11:25:15.164309 #1]  INFO -- : 
I, [2023-03-13T11:25:15.165444 #1]  INFO -- : > chown postgres:postgres /shared/postgres_run
I, [2023-03-13T11:25:15.182370 #1]  INFO -- : 
I, [2023-03-13T11:25:15.183423 #1]  INFO -- : > chmod 775 /shared/postgres_run
I, [2023-03-13T11:25:15.248940 #1]  INFO -- : 
I, [2023-03-13T11:25:15.249966 #1]  INFO -- : > rm -fr /var/run/postgresql
I, [2023-03-13T11:25:15.269133 #1]  INFO -- : 
I, [2023-03-13T11:25:15.270288 #1]  INFO -- : > ln -s /shared/postgres_run /var/run/postgresql
I, [2023-03-13T11:25:15.314538 #1]  INFO -- : 
I, [2023-03-13T11:25:15.315922 #1]  INFO -- : > socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container ; exit 1
2023/03/13 11:25:16 socat[18] E connect(6, AF=1 "/shared/postgres_run/.s.PGSQL.5432", 36): No such file or directory
I, [2023-03-13T11:25:16.264579 #1]  INFO -- : 
I, [2023-03-13T11:25:16.265205 #1]  INFO -- : > rm -fr /shared/postgres_run/.s*
I, [2023-03-13T11:25:16.330415 #1]  INFO -- : 
I, [2023-03-13T11:25:16.331258 #1]  INFO -- : > rm -fr /shared/postgres_run/*.pid
I, [2023-03-13T11:25:16.334530 #1]  INFO -- : 
I, [2023-03-13T11:25:16.335427 #1]  INFO -- : > mkdir -p /shared/postgres_run/13-main.pg_stat_tmp
I, [2023-03-13T11:25:16.339258 #1]  INFO -- : 
I, [2023-03-13T11:25:16.340137 #1]  INFO -- : > chown postgres:postgres /shared/postgres_run/13-main.pg_stat_tmp
I, [2023-03-13T11:25:16.342468 #1]  INFO -- : 
I, [2023-03-13T11:25:16.410983 #1]  INFO -- : File > /etc/service/postgres/run  chmod: +x  chown: 
I, [2023-03-13T11:25:16.416328 #1]  INFO -- : File > /etc/service/postgres/log/run  chmod: +x  chown: 
I, [2023-03-13T11:25:16.421556 #1]  INFO -- : File > /etc/runit/3.d/99-postgres  chmod: +x  chown: 
I, [2023-03-13T11:25:16.428238 #1]  INFO -- : File > /root/upgrade_postgres  chmod: +x  chown: 
I, [2023-03-13T11:25:16.429045 #1]  INFO -- : > chown -R root /var/lib/postgresql/13/main
I, [2023-03-13T11:26:07.923757 #1]  INFO -- : 
I, [2023-03-13T11:26:08.425452 #1]  INFO -- : > [ ! -e /shared/postgres_data ] && install -d -m 0755 -o postgres -g postgres /shared/postgres_data && sudo -E -u postgres /usr/lib/postgresql/13/bin/initdb -D /shared/postgres_data || exit 0
I, [2023-03-13T11:26:08.612014 #1]  INFO -- : 
I, [2023-03-13T11:26:08.612768 #1]  INFO -- : > chown -R postgres:postgres /shared/postgres_data
I, [2023-03-13T11:26:09.223581 #1]  INFO -- : 
I, [2023-03-13T11:26:09.224698 #1]  INFO -- : > chown -R postgres:postgres /var/run/postgresql
I, [2023-03-13T11:26:09.227553 #1]  INFO -- : 
I, [2023-03-13T11:26:09.228389 #1]  INFO -- : > /root/upgrade_postgres
I, [2023-03-13T11:26:09.285168 #1]  INFO -- : 
I, [2023-03-13T11:26:09.285919 #1]  INFO -- : > rm /root/upgrade_postgres
I, [2023-03-13T11:26:09.288235 #1]  INFO -- : 
I, [2023-03-13T11:26:09.464138 #1]  INFO -- : Replacing data_directory = '/var/lib/postgresql/13/main' with data_directory = '/shared/postgres_data' in /etc/postgresql/13/main/postgresql.conf
I, [2023-03-13T11:26:09.465421 #1]  INFO -- : Replacing (?-mix:#?listen_addresses *=.*) with listen_addresses = '*' in /etc/postgresql/13/main/postgresql.conf
I, [2023-03-13T11:26:09.466207 #1]  INFO -- : Replacing (?-mix:#?synchronous_commit *=.*) with synchronous_commit = $db_synchronous_commit in /etc/postgresql/13/main/postgresql.conf
I, [2023-03-13T11:26:09.466702 #1]  INFO -- : Replacing (?-mix:#?shared_buffers *=.*) with shared_buffers = $db_shared_buffers in /etc/postgresql/13/main/postgresql.conf
I, [2023-03-13T11:26:09.467257 #1]  INFO -- : Replacing (?-mix:#?work_mem *=.*) with work_mem = $db_work_mem in /etc/postgresql/13/main/postgresql.conf
I, [2023-03-13T11:26:09.467687 #1]  INFO -- : Replacing (?-mix:#?default_text_search_config *=.*) with default_text_search_config = '$db_default_text_search_config' in /etc/postgresql/13/main/postgresql.conf
I, [2023-03-13T11:26:09.468143 #1]  INFO -- : > install -d -m 0755 -o postgres -g postgres /shared/postgres_backup
I, [2023-03-13T11:26:09.761975 #1]  INFO -- : 
I, [2023-03-13T11:26:09.763351 #1]  INFO -- : Replacing (?-mix:#?checkpoint_segments *=.*) with checkpoint_segments = $db_checkpoint_segments in /etc/postgresql/13/main/postgresql.conf
I, [2023-03-13T11:26:09.764536 #1]  INFO -- : Replacing (?-mix:#?logging_collector *=.*) with logging_collector = $db_logging_collector in /etc/postgresql/13/main/postgresql.conf
I, [2023-03-13T11:26:09.765473 #1]  INFO -- : Replacing (?-mix:#?log_min_duration_statement *=.*) with log_min_duration_statement = $db_log_min_duration_statement in /etc/postgresql/13/main/postgresql.conf
I, [2023-03-13T11:26:09.791036 #1]  INFO -- : Replacing (?-mix:^#local +replication +postgres +peer$) with local replication postgres  peer in /etc/postgresql/13/main/pg_hba.conf
I, [2023-03-13T11:26:09.792174 #1]  INFO -- : Replacing (?-mix:^host.*all.*all.*127.*$) with host all all 0.0.0.0/0 md5 in /etc/postgresql/13/main/pg_hba.conf
I, [2023-03-13T11:26:09.792950 #1]  INFO -- : Replacing (?-mix:^host.*all.*all.*::1\/128.*$) with host all all ::/0 md5 in /etc/postgresql/13/main/pg_hba.conf
I, [2023-03-13T11:26:09.793444 #1]  INFO -- : > HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/13/bin/postmaster -D /etc/postgresql/13/main
I, [2023-03-13T11:26:09.795665 #1]  INFO -- : > sleep 5
I, [2023-03-13T11:26:14.820284 #1]  INFO -- : 
I, [2023-03-13T11:26:14.821311 #1]  INFO -- : > su postgres -c 'createdb discourse' || true
createdb: error: could not connect to database template1: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
	Is the server running locally and accepting connections on that socket?
I, [2023-03-13T11:26:21.603565 #1]  INFO -- : 
I, [2023-03-13T11:26:21.604284 #1]  INFO -- : > su postgres -c 'psql discourse -c "create user discourse;"' || true
2023-03-13 11:26:22.014 UTC [41] LOG:  starting PostgreSQL 13.10 (Debian 13.10-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2023-03-13 11:26:22.020 UTC [41] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2023-03-13 11:26:22.021 UTC [41] LOG:  listening on IPv6 address "::", port 5432
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
	Is the server running locally and accepting connections on that socket?
I, [2023-03-13T11:26:22.036057 #1]  INFO -- : 
I, [2023-03-13T11:26:22.039351 #1]  INFO -- : > su postgres -c 'psql discourse -c "grant all privileges on database discourse to discourse;"' || true
2023-03-13 11:26:22.047 UTC [41] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-03-13 11:26:22.723 UTC [53] LOG:  database system was shut down at 2023-03-13 10:30:34 UTC
2023-03-13 11:26:22.754 UTC [54] postgres@discourse FATAL:  the database system is starting up
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  the database system is starting up
I, [2023-03-13T11:26:22.757656 #1]  INFO -- : 
I, [2023-03-13T11:26:22.758335 #1]  INFO -- : > su postgres -c 'psql discourse -c "alter schema public owner to discourse;"'
2023-03-13 11:26:22.811 UTC [58] postgres@discourse FATAL:  the database system is starting up
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  the database system is starting up
I, [2023-03-13T11:26:22.814281 #1]  INFO -- : 
I, [2023-03-13T11:26:22.815016 #1]  INFO -- : Terminating async processes
I, [2023-03-13T11:26:22.815325 #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/postgresql/13/bin/postmaster -D /etc/postgresql/13/main pid: 41
2023-03-13 11:26:22.815 UTC [41] LOG:  received fast shutdown request
2023-03-13 11:26:22.928 UTC [61] LOG:  shutting down
2023-03-13 11:26:22.971 UTC [41] LOG:  database system is shut down


FAILED
--------------------
Pups::ExecError: su postgres -c 'psql discourse -c "alter schema public owner to discourse;"' failed with return #<Process::Status: pid 55 exit 2>
Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'
exec failed with the params "su postgres -c 'psql $db_name -c \"alter schema public owner to $db_user;\"'"
bootstrap failed with exit code 2
** 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.
0eed82a57ac12afa9bd1f7fe56c9d876fd06661813daa26f568dfc4bf3bd13e7

This is a standard install?

It looks like postgres is still starting up. Is the cpu very slow?

It seems possible postgres is somehow configured to use a non-standard port.

Try

ls -al /var/discourse/shared/standalone/postgres_run

On my installation, I see

total 28
drwxrwxr-x  5 systemd-resolve input   4096 Jan 26 15:43 .
drwxr-xr-x 13 root            root    4096 Jan 27  2021 ..
drwxr-x---  2 lxd             mlocate 4096 Jun  8  2020 10-main.pg_stat_tmp
drwxr-x---  2 lxd             mlocate 4096 Jan 27  2021 12-main.pg_stat_tmp
drwxr-xr-x  2 systemd-resolve input   4096 Mar 14 15:06 13-main.pg_stat_tmp
-rw-r--r--  1 systemd-resolve input      4 Jan 26 15:43 13-main.pid
srwxrwxrwx  1 systemd-resolve input      0 Mar 14 15:06 .s.PGSQL.5432
-rw-------  1 systemd-resolve input     62 Mar 14 15:06 .s.PGSQL.5432.lock

@Ed_S
It’s standard instalation, not modifiying any config.

@pfaffman
Yes it’s a standard installaition following discourse/INSTALL-cloud.md at main · discourse/discourse · GitHub

I had already found out why it’s not working, it had something to do with let’s encrypt.

It was probably rate limited hence it’s not issuing the ssl cert.

I had to disable letsencrypt in app.yaml and use my own ssl crt/key combo and rebuild again.

And it’s working perfectly now, restored the data and completed the server migration.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.