'pg_autoctl show uri' command reports 'ERROR Connection to database failed: could not translate host name "<wrong_monitor_host_name>" to address: Name or service not known'
search cancel

'pg_autoctl show uri' command reports 'ERROR Connection to database failed: could not translate host name "<wrong_monitor_host_name>" to address: Name or service not known'

book

Article ID: 296392

calendar_today

Updated On:

Products

VMware Tanzu Greenplum

Issue/Introduction

We receive the error below when executing the command "pg_autoctl show uri --pgdata <data_dir>" on monitor server:
20:30:39 40100 WARN  Failed to connect to "postgres://autoctl_node@<wrong_monitor_host_name>:5432/pg_auto_failover?sslmode=require", retrying until the server is ready
20:30:41 40100 ERROR Connection to database failed: could not translate host name "<wrong_host_name>" to address: Name or service not known

Meanwhile, the hostname is set correctly in both /etc/hostname and /etc/hosts.
The cause of the issue could be due to the fact that we set the wrong monitor host name when adding worker nodes or we changed monitor hostname after the pg_autofailover environment was configured.

Environment

Product Version: 12.5

Resolution

Check the correctness of "hostname" in the file "pg_autoctl.cfg", which should typically be located at a subdirectory of  /home/<your_postgres_user>/.config directory. And modify it to the correct hostname of the monitor host.