I recently stopped the postgresql database (that was working perfectly), and after a couple of days, when I try to start it, I get the errors:

2011-01-03 23:56:27 CLST LOG:  could not translate host name "localhost", service "5432" to address: Name or service not known
2011-01-03 23:56:27 CLST WARNING:  could not create listen socket for "localhost"
2011-01-03 23:56:27 CLST FATAL:  could not create any TCP/IP sockets

I'm running Ubuntu 9.1, and I'm using the usuals

/etc/init.d/postgresql-8.4 start and stop

Any hints ?

  • Are you running this as root? Try running it with sh -x /etc/init.d/postgresql-8.4 start and adding the output. – Andrew M. Jan 4 '11 at 4:24
  • Here's the output: pastebin.com/trQchjur – xain Jan 5 '11 at 1:40

Check ownership and permissions on /etc/hosts?

Specify in the config to isolate the problem.

| improve this answer | |
  • The problem was -rw------- in hosts file. Thanks a lot. – xain Jan 18 '11 at 2:02
  • 1
    The problem was -rw--------, but what should it have been? I have the same issue. Shame the solution isn't here :-( – Peter Snow Aug 28 '13 at 13:58
  • 1
    I don't know off-hand. Try 644. – SabreWolfy Aug 28 '13 at 21:14
  • 1
    @SabreWolfy is right : ) sudo chmod 644 hosts fixed it for me – thinklinux Dec 12 '14 at 14:07

Either your /etc/hosts or /etc/nsswitch.conf are messed up, nscd, if in use, is behaving crazily, or something is busted in libc.

| improve this answer | |
  • No modifications on either files and not using nscd; any hints on how to troubleshoot libc? – xain Jan 5 '11 at 1:59
  • I agree that this looks like a problem with /etc/hosts or something similar. Why was postgres stopped in the first place? For some sort of maintenance? What happened during the maintenance? The clues are probably there. Otherwise, make sure there is a localhost entry in /etc/hosts (and that it points to the loopback address) and that there is a network interface listening on this address. – bogeymin Jan 6 '11 at 15:01
  • Thanks for your reply. Postgres down due to migration preparations to mysql; new domain entries added to bind configuration; localhost present and pointing to in hosts file and lo interface listening in that address. – xain Jan 8 '11 at 11:52

First, I'd simply doublecheck that I can resolve "localhost" on the machine by attempting to ping it. Then. ensure that no other service is using that port with something line "netstat -ln | grep 5432".

pgcluster will not start if you have another service, or instance of pgsql, using the same port on the machine even if this port is on a separate network adapter. If this is the case, you could simply attempt to change the port number within your postgresql.cf file in order to get pgsql back up.

| improve this answer | |
  • 1
    Thanks for your reply, "ping localhost" is ok and "netstat -ln | grep 5432" returns no entries. – xain Jan 17 '11 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.