LOG: could not translate host name “localhost”, service “5432″ to address: Name or service not known
Posted by alex in Errors at 3:16 AMI 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.
|
|
|
|




Entries (RSS)
Thank you! It really helped me.
[Reply]
alex Reply:
July 19th, 2012 at 12:55 PM
Hello Bernard,
No problem. Thanks for taking the time to leave feedback.
Thanks.
alex
[Reply]
No such luck here. localhost is defined in /etc/hosts, and /etc/hosts is world readable, but I still get:
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
localhost definitely resolves, as I can ping and ssh to it. And nothing else is listening to port 5432.
[Reply]
alex Reply:
November 20th, 2012 at 7:14 PM
Hello arth1,
You might try changing the listen host from localhost to 127.0.0.1 or a specific interface IP address to see if that resolves your problem.
Thanks.
alex
[Reply]
This Helped me ALOT .. had a long day trying to figure it out.
Thank you Alex
[Reply]
alex Reply:
December 22nd, 2012 at 4:43 PM
Hello Cliff,
No problem. Thanks for taking the time to leave feedback.
Thanks.
alex
[Reply]
Hello,
This cost a lot of head pain/hours digging and debugging, thank Mr Alex.
[Reply]
alex Reply:
January 31st, 2013 at 4:59 PM
Hello SIFE,
No problem! Thanks for posting feedback!
Thanks.
alex
[Reply]