502 Bad Gateway error."could not translate host name 'localhost'":
# systemctl status postgres
* postgres.service - Postgres
Loaded: loaded (/etc/systemd/system/postgres.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Day YYYY-MM-DD HH:MM:SS UTC;
Process: 910 ExecStartPre=/usr/bin/sh -c /opt/vmware/vcf/commonsvcs/scripts/postgres/postgres-upgrade.sh /usr/pgsql/15/bin/ 15 (code=exited, status=0/SUCCESS)
Process: 920 ExecStart=/usr/pgsql/15/bin/pg_ctl start -D ${PGDATA} -s -w -t 270 (code=exited, status=1/FAILURE)
MM DD HH:MM:SS <sddc_manager_fqdn> pg_ctl[940]: YYYY-MM-DD HH:MM:SS UTC [940] LOG: starting PostgreSQL 15.12 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 10.5.0, 64-bit
MM DD HH:MM:SS <sddc_manager_fqdn> pg_ctl[940]: YYYY-MM-DD HH:MM:SS UTC [940] LOG: could not translate host name "localhost", service "5432" to address: Temporary failure in name resolution
MM DD HH:MM:SS <sddc_manager_fqdn> pg_ctl[940]: YYYY-MM-DD HH:MM:SS UTC [940] WARNING: could not create listen socket for "localhost"
MM DD HH:MM:SS <sddc_manager_fqdn> pg_ctl[940]: YYYY-MM-DD HH:MM:SS UTC [940] FATAL: could not create any TCP/IP sockets
MM DD HH:MM:SS <sddc_manager_fqdn> pg_ctl[940]: YYYY-MM-DD HH:MM:SS UTC [940] LOG: database system is shut down
MM DD HH:MM:SS <sddc_manager_fqdn> pg_ctl[920]: pg_ctl: could not start server
MM DD HH:MM:SS <sddc_manager_fqdn> pg_ctl[920]: Examine the log output.
MM DD HH:MM:SS <sddc_manager_fqdn> systemd[1]: postgres.service: Control process exited, code=exited, status=1/FAILURE
MM DD HH:MM:SS <sddc_manager_fqdn> systemd[1]: postgres.service: Failed with result 'exit-code'.
MM DD HH:MM:SS <sddc_manager_fqdn> systemd[1]: Failed to start Postgres./etc/hosts" file is commented out or the hosts file is blank.# Begin /etc/hosts (network card version)
# End /etc/hosts (network card version)
# VAMI EDIT BEGIN
# Generated by Studio VAMI service. Do not modify manually.
# 127.0.0.1 <sddc_manager_fqdn> <sddc_manager_hostname> localhost
# :: 1 <sddc_manager_fqdn> <sddc_manager_hostname> localhost ipv6-localhost ipv6-loopback
# VAMI EDIT END
The /etc/hosts file on the SDDC Manager appliance is missing the loopback address mapping or the entry is commented out. PostgreSQL requires localhost resolution to bind its internal communication sockets. Without this, the database service fails, causing a 502 error at the NGINX proxy layer.
cp /etc/hosts /etc/hosts.backup/etc/hosts file: vi /etc/hosts#Begin /etc/hosts (network card version)127.0.0.1 localhost.localdomain127.0.0.1 localhost127.0.0.1 photon#End /etc/hosts (network card version)Esc + :wq!' and press Enter to exit vi editor.cat /etc/hostsFor further assistance, see Contact Broadcom Support. To track updates on this issue, subscribe to this article.