question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Could not connect to target postmaster

See original GitHub issue

Hello,

Getting below error while trying to upgrade pg13 to pg14 using 2.1-p5 Image version.

postgres@pg-test-1:~$ env | grep -i PGVERSION PGVERSION=14

`postgres@pg-test-1:~$ python3 /scripts/inplace_upgrade.py 2 2022-05-26 05:01:04,688 inplace_upgrade INFO: No PostgreSQL configuration items changed, nothing to reload. 2022-05-26 05:01:04,732 inplace_upgrade INFO: establishing a new patroni connection to the postgres cluster 2022-05-26 05:01:04,799 inplace_upgrade INFO: Cluster pg-test is ready to be upgraded 2022-05-26 05:01:04,800 inplace_upgrade INFO: initdb config: [{‘locale’: ‘en_US.UTF-8’}, {‘encoding’: ‘UTF8’}, ‘data-checksums’] The files belonging to this database system will be owned by user “postgres”. This user must also own the server process.

The database cluster will be initialized with locale “en_US.UTF-8”. The default text search configuration will be set to “english”.

Data page checksums are enabled.

creating directory /home/postgres/pgdata/pgroot/data_new … ok creating subdirectories … ok selecting dynamic shared memory implementation … posix selecting default max_connections … 100 selecting default shared_buffers … 128MB selecting default time zone … Etc/UTC creating configuration files … ok running bootstrap script … ok performing post-bootstrap initialization … ok syncing data to disk … ok

initdb: warning: enabling “trust” authentication for local connections You can change this by editing pg_hba.conf or using the option -A, or –auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

/usr/lib/postgresql/14/bin/pg_ctl -D /home/postgres/pgdata/pgroot/data_new -l logfile start

2022-05-26 05:01:06,067 inplace_upgrade INFO: Dropping extensions from the cluster which could be incompatible 2022-05-26 05:01:06,073 inplace_upgrade INFO: Executing “DROP EXTENSION IF EXISTS amcheck_next” in the database=“postgres” 2022-05-26 05:01:06,079 inplace_upgrade INFO: Executing “DROP EXTENSION IF EXISTS amcheck_next” in the database=“demosession” 2022-05-26 05:01:06,085 inplace_upgrade INFO: Executing “DROP EXTENSION IF EXISTS amcheck_next” in the database=“template1” 2022-05-26 05:01:06,086 inplace_upgrade INFO: Executing pg_upgrade --check Performing Consistency Checks on Old Live Server

Checking cluster versions ok Checking database user is the install user ok Checking database connection settings ok Checking for prepared transactions ok Checking for system-defined composite types in user tables ok Checking for reg* data types in user tables ok Checking for contrib/isn with bigint-passing mismatch ok Checking for user-defined encoding conversions ok Checking for user-defined postfix operators ok

failure Consult the last few lines of “pg_upgrade_server.log” for the probable cause of the failure.

connection to server on socket “/home/postgres/pgdata/pgroot/data_upgrade/.s.PGSQL.50432” failed: No such file or directory Is the server running locally and accepting connections on that socket?

could not connect to target postmaster started with the command: “/usr/lib/postgresql/14/bin/pg_ctl” -w -l “pg_upgrade_server.log” -D “/home/postgres/pgdata/pgroot/data_new” -o “-p 50432 -b -c synchronous_commit=off -c fsync=off -c full_page_writes=off -c vacuum_defer_cleanup_age=0 -c timescaledb.restoring=‘on’ -c listen_addresses=‘’ -c unix_socket_permissions=0700 -c unix_socket_directories=‘/home/postgres/pgdata/pgroot/data_upgrade’” start Failure, exiting 2022-05-26 05:01:06,803 inplace_upgrade ERROR: pg_upgrade --check failed, more details in the /home/postgres/pgdata/pgroot/data_upgrade`

shared_preload_libraries shared_preload_libraries: pgaudit,bg_mon,pg_stat_statements,pgextwlist,pg_auth_mon,set_user,pg_cron,pg_stat_kcache

pg_upgrade_server.log

`

pg_upgrade run on Thu May 26 05:01:06 2022

command: “/usr/lib/postgresql/13/bin/pg_ctl” -w -l “pg_upgrade_server.log” -D “/home/postgres/pgdata/pgroot/data” -o “-p 50432 -c autovacuum=off -c autovacuum_freeze_max_age=2000000000 -c listen_addresses=‘’ -c unix_socket_permissions=0700” start >> “pg_upgrade_server.log” 2>&1 pg_ctl: another server might be running; trying to start server anyway waiting for server to start…2022-05-26 05:01:06 UTC [1730]: [1-1] 628f0992.6c2 0 FATAL: lock file “postmaster.pid” already exists 2022-05-26 05:01:06 UTC [1730]: [2-1] 628f0992.6c2 0 HINT: Is another postmaster (PID 76) running in data directory “/home/postgres/pgdata/pgroot/data”? stopped waiting pg_ctl: could not start server Examine the log output.

command: “/usr/lib/postgresql/14/bin/pg_ctl” -w -l “pg_upgrade_server.log” -D “/home/postgres/pgdata/pgroot/data_new” -o “-p 50432 -b -c synchronous_commit=off -c fsync=off -c full_page_writes=off -c vacuum_defer_cleanup_age=0 -c timescaledb.restoring=‘on’ -c listen_addresses=‘’ -c unix_socket_permissions=0700 -c unix_socket_directories=‘/home/postgres/pgdata/pgroot/data_upgrade’” start >> “pg_upgrade_server.log” 2>&1 waiting for server to start…2022-05-26 05:01:06 UTC [1764]: [1-1] 628f0992.6e4 0 LOG: pgaudit extension initialized 2022-05-26 05:01:06 UTC [1764]: [2-1] 628f0992.6e4 0 LOG: Auto detecting pg_stat_kcache.linux_hz parameter… 2022-05-26 05:01:06 UTC [1764]: [3-1] 628f0992.6e4 0 LOG: pg_stat_kcache.linux_hz is set to 500000 2022-05-26 05:01:06 UTC [1764]: [4-1] 628f0992.6e4 0 LOG: redirecting log output to logging collector process 2022-05-26 05:01:06 UTC [1764]: [5-1] 628f0992.6e4 0 HINT: Future log output will appear in directory “…/pg_log”. stopped waiting pg_ctl: could not start server Examine the log output.`

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
CyberDem0ncommented, May 27, 2022

command: “/usr/lib/postgresql/14/bin/pg_ctl” -w -l “pg_upgrade_server.log” -D “/home/postgres/pgdata/pgroot/data_new” -o “-p 50432 -b -c synchronous_commit=off -c fsync=off -c full_page_writes=off -c vacuum_defer_cleanup_age=0 -c timescaledb.restoring=‘on’ -c listen_addresses=‘’ -c unix_socket_permissions=0700 -c unix_socket_directories=‘/home/postgres/pgdata/pgroot/data_upgrade’” start >> “pg_upgrade_server.log” 2>&1 waiting for server to start…2022-05-26 05:01:06 UTC [1764]: [1-1] 628f0992.6e4 0 LOG: pgaudit extension initialized 2022-05-26 05:01:06 UTC [1764]: [2-1] 628f0992.6e4 0 LOG: Auto detecting pg_stat_kcache.linux_hz parameter… 2022-05-26 05:01:06 UTC [1764]: [3-1] 628f0992.6e4 0 LOG: pg_stat_kcache.linux_hz is set to 500000 2022-05-26 05:01:06 UTC [1764]: [4-1] 628f0992.6e4 0 LOG: redirecting log output to logging collector process 2022-05-26 05:01:06 UTC [1764]: [5-1] 628f0992.6e4 0 HINT: Future log output will appear in directory “…/pg_log”. stopped waiting pg_ctl: could not start server Examine the log output.

It fails to start the new cluster (data_new). You have to figure out why. Details are in postgres logs (“…/pg_log”).

0reactions
Psharm89commented, May 27, 2022

Changed clientcert:verify-ca in pg_hba.conf is worked fine

hostssl all all all md5 clientcert=1

to

hostssl all all all md5 clientcert=verify-ca


postgres@pg-test-1:~$ pg_upgrade --old-bindir /usr/lib/postgresql/13/bin --new-bindir /usr/lib/postgresql/14/bin --old-datadir /home/postgres/pgdata/pgroot/data --new-datadir /home/postgres/pgdata/pgroot/data_new --old-options '-c config_file=/home/postgres/pgdata/pgroot/data/postgresql.conf' --new-options '-c config_file=/home/postgres/pgdata/pgroot/data_new/postgresql.conf' --user=postgres --check
Performing Consistency Checks on Old Live Server
------------------------------------------------
Checking cluster versions                                   ok
Checking database user is the install user                  ok
Checking database connection settings                       ok
Checking for prepared transactions                          ok
Checking for system-defined composite types in user tables  ok
Checking for reg* data types in user tables                 ok
Checking for contrib/isn with bigint-passing mismatch       ok
Checking for user-defined encoding conversions              ok
Checking for user-defined postfix operators                 ok
Checking for presence of required libraries                 ok
Checking database user is the install user                  ok
Checking for prepared transactions                          ok
Checking for new cluster tablespace directories             ok

*Clusters are compatible*
 


Read more comments on GitHub >

github_iconTop Results From Across the Web

psql cant connect to PostgreSQL server (postmaster) on IP ...
It throws: psql: could not connect to server: Connection refused Is the server running on host XXXXXX and accepting TCP/IP connections on port ......
Read more >
Thread: pg_upgrade could not connect to server
could not connect to old postmaster started with the command: > "C:\Program Files\PostgreSQL\9.3\bin/pg_ctl" -w -l "pg_upgrade_server.log" ...
Read more >
Problem upgrading Postgres to V13 on Big Sur #410 - GitHub
could not connect to target postmaster started with the command: "/usr/local/opt/postgresql/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D ...
Read more >
Solve PSQL error: could not connect to server
pg_ctl is a utility for starting, stopping, or restarting the PostgreSQL backend server (postmaster), or displaying the status of a running ...
Read more >
PostgreSQL: pg_upgrade 9.5 to 13 failing with "connection to ...
Show activity on this post. I'm trying to upgrade a 9.5 server to 13 but the pg_upgrade process is failing after the main...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found