I have a strange situation, I have created a second postgres server that will eventually become a slave to my current master, anyway for testing purposes I have currently installed postgres, and testing connections from other hosts.

In my postgresql.conf I have a nice an easy: listen_addresses = '*'# what IP address(es) to listen on; # comma-separated list of addresses; # defaults to 'localhost'; use '*' for all # (change requires restart) port = 5432

Then In my pg_hba.conf I have:

# allow all connections, testing only, comment in production
host    all             all                  trust

This postgres server is running in a freebsd jail, so has two IP addresses:

root@postgres ~# telnet 5432                     
telnet: connect to address Connection refused
telnet: Unable to connect to remote host

root@postgres ~# telnet 5432                                                                                                                                                                          1
Connected to
Escape character is '^]'.
^CConnection closed by foreign host.

root@postgres ~# ifconfig                                                                                                           
em1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    ether 00:25:90:27:d8:24
    inet netmask 0xffffffff broadcast 
    media: Ethernet autoselect (1000baseT <full-duplex>)
    status: active
lo1: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
    inet netmask 0xffffffff 
    groups: lo 

So as you can see, I can on port 5432 but only using the loopback address, so then I try a simple

root@postgres ~# psql -h                   
psql: FATAL:  no pg_hba.conf entry for host "", user "root", database "root", SSL off

Why is this basic connection getting blocked, as my hba.conf has ALL and in addition why can I not connect via the local address of

netstat shows the following output:

Proto Recv-Q Send-Q Local Address          Foreign Address        (state)
tcp4       0      0  *.*                    LISTEN

NOTE.. I have another jail setup on another server with seemingly the same setup which works, thats on version 9.3.5 and this new server (with the issue) is on 9.6.3

EDIT: When changing config to listen on I get a netstat output:

Proto Recv-Q Send-Q Local Address          Foreign Address        (state)
tcp4       0      0  *.*                    LISTEN
tcp4       0      0         *.*                    LISTEN

You can see that SSH is successfully able to listen on the LAN address of (on port 3100) so it can't be a jail networking issue, it must be something postgres related.

  • Have you checked your Firewall configuration? – Alexander Tolkachev Aug 2 '17 at 11:06
  • Yes, should of stated that, disabled PF on this server for testing, and checked master network firewall, no blocked packets. – crooksey Aug 2 '17 at 11:17

PostgreSQL manual says about listen_addresses this:

listen_addresses (string)

Specifies the TCP/IP address(es) on which the server is to listen for connections from client applications. The value takes the form of a comma-separated list of host names and/or numeric IP addresses. The special entry * corresponds to all available IP interfaces. The entry allows listening for all IPv4 addresses and :: allows listening for all IPv6 addresses. If the list is empty, the server does not listen on any IP interface at all, in which case only Unix-domain sockets can be used to connect to it. The default value is localhost, which allows only local TCP/IP "loopback" connections to be made. While client authentication (Chapter 20) allows fine-grained control over who can access the server, listen_addresses controls which interfaces accept connection attempts, which can help prevent repeated malicious connection requests on insecure network interfaces. This parameter can only be set at server start.

May be there is some bug with * as listening parameter. Try to set it to, it force postgres to listen on all IP-addresses and could fix your issue.

  • That made no difference. – crooksey Aug 2 '17 at 13:30
  • @crooksey please show netstat -tldpn output with new config. – Alexander Tolkachev Aug 2 '17 at 14:22
  • See updated orignal post @alexander-tolkachev – crooksey Aug 2 '17 at 15:06

After noticing all these random problems with no apparent cause, I assumed something more the one configuration file was off, I un-installed postgres, cleaned the /var/db/postgres and /usr/etc/postgres folders and then re-installed.

Everything now works as expected, so I am assuming the installation originally silently failed.

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.