LOG: could not translate host name “localhost”, service “5432″ to address: Name or service not knownPosted by alex in Errors at 3:16 AM
I recently installed PostgreSQL on an Amazon Web Services CentOS instance however when I first attempted to start Postgres I received an error that I had never seen before. The pgstartup.log file located in /var/lib/pgsql contained the below data.
Error Contents Of pgstartup.log File:
LOG: could not translate host name "localhost", service "5432" to address: Name or service not known WARNING: could not create listen socket for "localhost" FATAL: could not create any TCP/IP sockets
To view the pgstartup.log file use the below command.
After viewing the error file I realized that for some reason there was no localhost configured by default on the AWS instance that was using a CentOS 5.3 base image. So to resolve the issue all I needed to do was add a hosts file to the /etc directory with the below contents.
Contents of /etc/hosts:
127.0.0.1 localhost localhost.localdomain
After adding the above to /etc/hosts I attempted to start Postgres again using the below command.
This time PostgreSQL started without an issue on the Amazon Web Services instance.