• Home »
  • Errors »
  • LOG: could not translate host name “localhost”, service “5432″ to address: Name or service not known

LOG: could not translate host name “localhost”, service “5432″ to address: Name or service not known

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.

less /var/lib/pgsql/pgstartup.log

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.

Start Postgres:

/etc/init.d/postgresql start

This time PostgreSQL started without an issue on the Amazon Web Services instance.

PostgreSQL 8.4 Official Documentation - Volume I. The SQL Language (Paperback)

By (author): The PostgreSQL Global Development Group


List Price: $34.99 USD
New From: $30.36 USD In Stock
Used from: $9.94 USD In Stock


List Price: $29.99 USD
New From: $8.49 USD In Stock
Used from: $0.80 USD In Stock

Share